template-aliases

How do template aliases affect template parameter deduction?

两盒软妹~` 提交于 2019-11-28 07:10:28
问题 In C++03, template parameter deduction does not occur in some contexts. For example: template <typename T> struct B {}; template <typename T> struct A { typedef B<T> type; }; template <typename T> void f(typename A<T>::type); int main() { B<int> b; f(b); // ERROR: no match } Here, int is not deduced for T , because a nested type such as A<T>::type is a non-deduced context. Had I written the function like this: template <typename T> struct B {}; template <typename T> void f(B<T>); int main() {

Can I specialize a class template with an alias template?

坚强是说给别人听的谎言 提交于 2019-11-27 15:05:33
问题 Here's a simple example: class bar {}; template <typename> class foo {}; template <> using foo<int> = bar; Is this allowed? 回答1: $ clang++ -std=c++0x test.cpp test.cpp:6:1: error: explicit specialization of alias templates is not permitted template <> ^~~~~~~~~~~ 1 error generated. Reference: 14.1 [temp.decls]/p3: 3 Because an alias-declaration cannot declare a template-id, it is not possible to partially or explicitly specialize an alias template. 回答2: Although direct specialization of the

C++ dynamic downcasting to class template having template template parameter being a class template or an alias template

拥有回忆 提交于 2019-11-27 07:25:18
问题 I hope the title makes sense. I probably miss vocabulary to express it correctly. Well, an exemple will probably be more clear. Problem for me is: dynamic downcasting returns 0 at run time in some of the following cases (written in comments). I'd like to know if it's a correct behaviour (using C++11), also why, and what can I do to make it work. Apparently, Templated and A::A_templated are treated as different classes, despite being defined as identical by using alias "using". Problem doesn't