c++ - Templates: how to pass a non-type argument object as a non-type argument to another template -


to avoid passing many constants on 8 bit system still keep code modular, use templates non-type (reference) arguments receiving constants. works without problems long pass parameter object "one level" deep.

if try use such templated object non type argument template, compiler refuses attempts declare such template:

struct params {constexpr params(int i){}}; extern constexpr params const p(1);  // compiles fine template <params const &p> class { }; a<p> a;  // not compile template <a<params const &> &a> class b { }; b<a> b; 

so question is: know how define template receives object of (non-type) template argument?

you defining a template non-type parameter p (of type params const&) in definition of b passing type template a (namely type params const&). you're treating a has type parameter though doesn't.

but works fine:

template <a<p> &a> class b { }; b<a> b; 

if want b accept argument of type a<p> any p, need template argument p.

template <params const& p, a<p> &a> class b { }; b<p, a> b; 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -