What does this syntax mean ?

Hi, i found this piece of code in folly's source, and i want to know what it means. my best guess was template specialization but i'm not sure.
1
2
   template<> char const dynamic::TypeInfo<T>::name[]=str;
   template<> dynamic::Type const dynamic::TypeInfo<T>::type = typen;


by the way, dynamic is a class that ingerits boost::operators and has some enumerated types.
Was it:
1
2
3
4
5
6
7
#define DEF_TYPE(T, str, typen) \
template<> char const dynamic::TypeInfo<T>::name[] = str; \
template<> dynamic::Type const dynamic::TypeInfo<T>::type = typen

DEF_TYPE(void*, "null", dynamic::NULLT);
DEF_TYPE(bool, "boolean", dynamic::BOOL);
#undef DEF_TYPE 

If yes, then we can clearly say that asking about a code fragment without its context poses an insane challenge.

With the context it easier to say that preprocessor has to do its black magic first before we even see the C++ code whose syntax should be explained.
yes it is, so ?
The DEF_TYPE(bool, "boolean", dynamic::BOOL); thus means:
1
2
3
4
5
template<> // explicit specialization for T = bool
char const dynamic::TypeInfo<bool>::name[] = "boolean";

template<> // explicit specialization for T = bool
dynamic::Type const dynamic::TypeInfo<bool>::type = dynamic::BOOL;

http://en.cppreference.com/w/cpp/language/template_specialization

Result looks like static member variable definition for specific type (dynamic::TypeInfo<bool>).
Topic archived. No new replies allowed.