c++ - When is a type equal (template specialization)? -


i store configuration type:

using config1 = config<x, y, z>; using config2 = config<a, b, c>; using config3 = config<x, y, z>; 

for each config, there's class template specialization, more configuration work:

template <class config> myclass;  template <> myclass<config1>{...}  template <> myclass<config2>{...}  template <> myclass<config3>{...} 

now, see, config1 happens have same definition config3.

the question is:

  1. which specialization taken config1 , config3, or: when type equal? it's name or it's actual content?

  2. if it's actual content, how can achieve config1 , config3 invoke different specializations?

config1 , config3 same type, therefore specialization fail with

error: redefinition of 'struct myclass<config<x, y, z> >' struct myclass<config3>{}; 

you can use inheritance create new type:

using config1 = config<x, y, z>; struct config3 : config1{};  

live example: https://ideone.com/4grlaw


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -