Namespaces
Variants
Views
Actions

Talk:cpp/language/type alias

From cppreference.com

The C++ standard seems to use the terminology "template alias" instead of "type alias". Should this page be renamed? --Legalize (talk) 15:00, 21 January 2016 (PST)

both "type alias" and "alias template" are terms used in the standard ("template alias" is used in a couple places, which appear to be editorial bugs). The page title is currently "type alias, alias template", reflecting that exact naming. If you are referring to the URL, I don't know what's a better one: just "cpp/language/alias" would be wrong as there are namespace aliases elsewhere, "cpp/language/type_alias_and_alias_template" would be unusually long. Perhaps "cpp/language/alias_template" makes sense because type alias occupies a relatively minor section here. --Cubbi (talk) 15:21, 21 January 2016 (PST)


sample program produces warnings. also it would be better if it produces some output

 Compiler messages:
 
 main.cpp: In instantiation of 'void g(const ContainerType&) [with ContainerType = Container<int>]':
 main.cpp:49:6:   required from here
 main.cpp:34:69: warning: unused variable 'n' [-Wunused-variable]
    34 | void g(const ContainerType& c) { typename ContainerType::value_type n; }
       |                                                                     ^
 main.cpp:34:29: warning: unused parameter 'c' [-Wunused-parameter]
    34 | void g(const ContainerType& c) { typename ContainerType::value_type n; }
       |        11:07, 1 July 2022 (PDT)11:07, 1 July 2022 (PDT)11:07, 1 July 2022 (PDT)11:07, 1 July 2022 (PDT)~^
 main.cpp: In instantiation of 'int fpoly_only(T) [with T = S; <template-parameter-1-2> = void]':
 main.cpp:52:15:   required from here
 main.cpp:42:18: warning: unused parameter 't' [-Wunused-parameter]
    42 | int fpoly_only(T t) { return 1; }
     |

Also what is the type alias equivalent of

     typedef void (F)(int,int) ;

Is it this?

     using F = void (&)(int,int);

It would be helpful to have more examples like this

--2601:184:C300:9790:844B:1F23:D587:A544 11:07, 1 July 2022 (PDT)

re last question, the type-id link on this page goes to the page that explains type naming in more detail, key detail being "exactly the syntax of a declaration of a variable or function, with the identifier omitted". Thus, using F = void(int,int) --Cubbi (talk) 21:38, 4 July 2022 (PDT)