[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-199846-105":53,"doc-detail-199846-en":126},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":119,"head_meta":121,"extra_data":123,"updated_unix":125},105,"en","typesafe-variable-length-function-and-template-argument-lists-proposal","Typesafe Variable-length Function and Template Argument Lists - Proposal","","Proposal addresses three related C++ template and call-argument limitations: inability to instantiate class/function templates with an arbitrarily long parameter list, inability to pass an arbitrary number of function arguments in a type-safe manner, and the argument forwarding problem. The resolution introduces syntax and semantics for variable-length template argument lists usable with both function templates (via explicit template argument specification) and class templates, plus a mechanism for building and forwarding argument lists to preserve type safety and semantics.",{"@graph":63,"@context":118},[64,80,101],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/typesafe-variable-length-function-and-template-argument-lists-proposal/199846/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/typesafe-variable-length-function-and-template-argument-lists-proposal/199846.png","ImageObject",442,249,{"name":88,"@type":89},"Ophelia","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-09-20","2026-09-04",true,{"@type":98,"interactionType":99,"userInteractionCount":73},"InteractionCounter",{"@type":100},"ViewAction",{"@type":102,"mainEntity":103},"FAQPage",[104,110,114],{"name":105,"@type":106,"acceptedAnswer":107},"What three problems does the proposal aim to solve in C++ templates and calls?","Question",{"text":108,"@type":109},"It targets (1) instantiating templates with arbitrarily long template-parameter lists, (2) passing an arbitrary number of function call arguments type-safely, and (3) the argument forwarding problem.","Answer",{"name":111,"@type":106,"acceptedAnswer":112},"How does the proposal enable variable-length template parameter lists?",{"text":113,"@type":109},"It adds a syntax for declaring an arbitrary number of extra template arguments by using an ellipsis-based termination (optionally with an identifier holding a tuple of the extra arguments).",{"name":115,"@type":106,"acceptedAnswer":116},"What is the core challenge in argument forwarding that the proposal addresses?",{"text":117,"@type":109},"Given an expression depending on generic parameters, it must be possible to write a forwarding callable so the forwarded call is equivalent to that expression without changing semantics, including deducing and preserving argument types.","https://schema.org",{"og:url":78,"og:type":120,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":122,"canonical":78},"index,follow",{"doc_id":124,"site_id":56},199846,1788507177,{"code":4,"msg":5,"data":127},{"doc_id":124,"user_id":128,"nickname":88,"user_avatar":129,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":130,"file_id":131,"file_url":132,"file_type":133,"file_size":134,"view_count":73,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":20,"language":135,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":136,"faqs":137,"seo_title":138,"seo_description":61,"update_tm":125,"read_time":47},7971461741311,"https://ap-avatar.wpscdn.com/avatar/74000253aff267980c6?x-image-process=image/resize,m_fixed,w_180,h_180&k=1779345379180704826","Typesafe Variable-length Function and Template Argument Lists  \nDouglas Gregor Gary Powell Jaakko J􀁿arvi  \nDocument number: N1483=03-0066  \nDate: 25 April 2003  \nProject: Programming Language C++, Evolution Working Group  \nReply-to: Douglas Gregor \u003C[gregod@cs.rpi.edu](gregod@cs.rpi.edu) >  \n1 Introduction  \nThis proposal addresses three problems under a uni􀀌ed framework:  \n􀀏 The inability to instantiate class and function templates with an arbitrarily-long list of template parameters.  \n􀀏 The inability to pass an arbitrary number of arguments to a function in a type-safe manner.  \n􀀏 The argument forwarding problem.  \nThe proposed resolution is to introduce a syntax and semantics for variable-length template argument lists (usable with function templates via explicit template argument speci􀀌cation and with class templates) along with a method of argument building using the same mechanism to pass an arbitrary number of function call arguments to a function in a typesafe manner.  \n2 Motivation  \n2.1 Variable-length template parameter lists  \nVariable-length template parameter lists (varargs) allow a class or function template to accept some number (possibly zero) of template arguments beyond the number of template parameters speci􀀌ed. This behavior can be simulated in C++ via a long list of defaulted template parameters, e.g., a typelist wrapper may appear as:  \nstruct unused;  \ntemplate\u003Ctypename T1 = unused, typename T2 = unused,  \ntypename T3 = unused, typename T4 = unused,  \n/* up to */ typename TN = unused> class list;  \nThis technique is used by the Boost Tuples library [10], for the speci􀀌cation of class template std::tuple\u003C> in the library TR [11], and in the Boost metaprogramming library [9] . Unfortunately, this method leads to very long type names in error messages (compilers tend to print the defaulted arguments) and very longmangled names. It is also not scalable to additional arguments without resorting to preprocessor magic [13] . In all of these libraries (and presumably many more), an implementation based on template varargs would be shorter and would not su􀀋er the limitations of the aforementioned implementation. The declaration of the list\u003C> template above may be:  \ntemplate\u003C . . .> class list;  \n[Doc. no: N1483=03-0066](Doc. no: N1483=03-0066) 2  \nThis language feature is primarily designed for library developers, and is drawn from experience in library development where these techniques have been simulated in one way or another [9, 12, 10, 5, 1] . Novice users aren't likely to use this feature, as generically manipulating heterogeneous type container (tuples, in this case) requires some degree of metaprogramming.  \n2.2 Typesafe Variable-length Function Parameter Lists  \nVariable-length function parameter lists allow more arguments to be passed to a function than are declared by the function. This feature is rarely used in C++ code (except for compatibility with C libraries), because passing non-POD types through ... invokes unde􀀌ned behavior. However, a typesafe form of such a feature would be useful in many contexts, e.g., for implementing a typesafe C++ printf that works for non-POD types. The lack of such a facility has resulted in odd syntax for formatting in the Boost.Format library [14]:  \nformat(\"writing %1%, x=%2%: %3%-th try\") % \"toto\" % 40 .23 % 50  \n2.3 Argument forwarding  \nThe forwarding problem, as described in [4], is:  \nFor a given expression E(a1 ; a2 ; :::; an ) that depends on the (generic) parameters a 1 ; a2 ; :::; an , it isnot possible to write a function (object) f such that f(a1 ; a2 ; :::; an ) is equivalent to E (a1 ; a2 ; :::; an ) .  \nThe primary issue with the argument forwarding problem is to deduce the types of a 1 ; a2 ; :::; an such that they can be forwarded to the underlying function E without changing the semantics of the expression. The common implementation idiom is to accept a (non-const) reference for each parameter, and to provide overloads for some number of arguments","cbCailuOfNoBeb9A","https://ap.wps.com/l/cbCailuOfNoBeb9A","pdf",167088,"English","# Introduction\n## Variable-length template parameter lists\n## Typesafe variable-length function parameter lists\n## Argument forwarding\n# Motivation\n## Variable-length template parameter lists\n## Typesafe variable-length function parameter lists\n## Argument forwarding\n# Syntax and Semantics\n## Variable-length template parameter lists","[{\"question\":\"What three problems does the proposal aim to solve in C++ templates and calls?\",\"answer\":\"It targets (1) instantiating templates with arbitrarily long template-parameter lists, (2) passing an arbitrary number of function call arguments type-safely, and (3) the argument forwarding problem.\"},{\"question\":\"How does the proposal enable variable-length template parameter lists?\",\"answer\":\"It adds a syntax for declaring an arbitrary number of extra template arguments by using an ellipsis-based termination (optionally with an identifier holding a tuple of the extra arguments).\"},{\"question\":\"What is the core challenge in argument forwarding that the proposal addresses?\",\"answer\":\"Given an expression depending on generic parameters, it must be possible to write a forwarding callable so the forwarded call is equivalent to that expression without changing semantics, including deducing and preserving argument types.\"}]","Typesafe Variable-length Function and Template Argument Lists - Proposal | PDF"]