c++ - Traits specialization -



c++ - Traits specialization -

i define storage type within trait specializations. cases not have define i.e. there no storage type specializations. of course of study using void type not way, i'm looking similar. i'm not sure if i'm heading right direction - 1 way utilize boolean type since take to the lowest degree space. right/good way overcome this. i'm not sure if such problem has been asked. did not know search for!

template<typename t> struct traits { } template<> struct traits<typea> { typedef std::vector<double> storage; } template<> struct traits<typeb> { typedef std::vector<string> storage; } template<> struct traits<typec> { //i not want specify storage type here. more not exist. //so right way define such type typedef ??void?? storage; } int main() { typename traits<typea>::storage mytype; /* domething */ }

just omit storage typedef doesn't create sense:

template<> struct traits<typec> { };

now usage of traits<typec>::storage becomes error, because doesn't name type.

other notes:

you need semicolons after struct declaration/definition. your traits template (not specialization) should have no body unless there 1 makes sense every type. is, should template <typename> struct traits;. cause usage of template argument doesn't create sense cause errors.

c++ typetraits

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -