I have some template struct defined in templates.h:
//templates.h
#ifndef TEMPLATES_H
#define TEMPLATES_H
template<typename Key = int, typename Value = Key>
struct array{
map<const Key, Value> data;
//Stuffs
};
/*explicit (full) specialization*/
template<>
template<typename Key>
struct array<Key, char>{
map<const Key, Value> data;
//Stuffs
};
#include "templates.cpp"
#endif
Trying to separate declarations (interface) from definitions (implementations), i did this in templates.cpp:
//templates.cpp
#ifdef TEMPLATES_H
#include "templates.h"
#endif
template<typename Key, char>
array<Key, char>::array(const Key& k, const char* v){ cout << "specialised array<T, char>"; }
inside main(), i test-drove:
//inside main();
array<int, char> out(1, "Just testing"); /*error 1: prototype for 'array<Key, char>::array(const Key&, const char*)' does not match any in class 'array<Key, char>'
error 2: candidate is: array<Key, char>::array(const array<Key, char>&)
*/
Question: I expected a call to array::array(Key, char) constructor; which is an explicit specialization of array::array(Key, Value), but got the error message commented above. what am i doing wrong, or how can i fix this ?.