Why does the the following attempt at overloading the constructor Foo::Foo
fail? Also, I'd appreciate alternatives/workarounds
#include <vector>
#include <type_traits>
namespace xyz
{
struct MemoryManager{};
template<typename T , typename Alloc=MemoryManager>
class vector
{
};
}
template<typename T, template<typename,typename> class V , typename A>
struct Foo
{
template<typename U = T ,
typename Dummy = typename std::enable_if<
std::is_same<std::vector<U>, V<U,A> >::value >::type >
Foo() // when instantiated with the std vector
{
}
template<typename U = T ,
typename Dummy = typename std::enable_if<
std::is_same<xyz::vector<U>, V<U,A> >::value >::type >
Foo() // when instantiated with my custom vector
{
}
};
int main()
{
}
Error message:
23:3: error: ‘template<class T, template<class, class> class V, class A> template<class U, class Dummy> Foo<T, V, A>::Foo()’ cannot be overloaded
Foo() // when instantiated with my custom vector
18:3: error: with ‘template<class T, template<class, class> class V, class A> template<class U, class Dummy> Foo<T, V, A>::Foo()’
Foo() // when instantiated with the std vector
Aucun commentaire:
Enregistrer un commentaire