Correct usage of C++ template template parameters -


i've trouble make use of template template parameters. here simplified example:

template <typename t>  struct foo {   t t; };  template <template <class x> class t> struct bar {   t<x> data;   x x; };  int main() {   bar<foo<int>> a; } 

the compiler (g++ (ubuntu 4.8.2-19ubuntu1) 4.8.2) reports following error:

main.cpp:8:5: error: ‘x’ not declared in scope    t<x> data;      ^  main.cpp:8:6: error: template argument 1 invalid    t<x> data;       ^ 

any idea what's wrong?

so make use of bar<foo<>>

template <typename t = int>  struct foo {   t t; };  template <typename t> struct baz {   t t; };  template <typename t> struct bar;  template <template <typename> class t, typename x> struct bar<t<x>> {   t<x> data;   x x; };  int main() {   bar<foo<>> a;   bar<baz<float>> b; } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -