The following does not compile
#include <iostream>
#include <type_traits>
// forward declaration of a type template
template<class T, class Alloc = std::allocator<T>> class std::vector;
template<class T>
struct is_vector : std::false_type { };
// using the forward declared type template
template<class T, class Alloc>
struct is_vector<std::vector<T, Alloc>> : std::true_type { };
#include <vector>
int main()
{
std::cout << is_vector<std::vector<int>>::value << std::endl;
}
I want to make sure that forward declared type templates (above the vector
) are actually non useable in specialization contexts and that it's not a faulty implementation to blame. Also why is this happening? I don't want to create an object of type vector<>
only use it as a tag to dispatch between specializations; doesn't inclusion of <vector>
at the point of instantiation suffice (call site of is_vector<>
) ?