How can I compile template class 'Append' from Alexandrescu A. "Modern C++ Design. Generic Programming and Design Patterns Applied"? -


alexandrescu in book implements template class 'append' appending type type list in way:

template <class tlist, class t> struct append;  template <> struct append<nulltype, nulltype> {     typedef nulltype result; };  template <class t> struct append<nulltype, t> {     typedef typelist_1(t) result; };  template <class head, class tail> struct append<nulltype, typelist<head, tail> > {     typedef typelist<head, tail> result; };  template <class head, class tail, class t> struct append<typelist<head, tail>, t> {     typedef typelist<head,         typename append<tail, t>::result>         result; }; 

all 'append' specializations accept not more 2 template arguments last 1 accepts 3 template arguments. trying compile code error

error c2977: 'append' : many template arguments 

this happens on either msvc compiler or gcc. 'append' implementation correct?

the append template struct accepts two, , 2 arguments: tlist , t.

all other entries specializations, describing special case, when value of t or tlist special. last append specialization special case where:

  • t type
  • tlist of form typelist<head, tail> head , tail arbitrary type names. presume typelist defined somewhere earlier 2-argument template.

if want create instance last specialization, have use typelist, e.g.

append< typelist<char, short>, int> object; 

(i have chosen char, short, int arbitrarily sake of example, , don't know if makes sense actual append implementation)


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -