Talk:cpp/language/function

Maybe your document is wrong in relation to function attributes?

http://en.cppreference.com/w/cpp/language/function

I seem to find that attributes should go in the same position as per a function definition, I have asked question on stack overflow but no answer, here is link to question with example code..

http://stackoverflow.com/questions/38516499/where-do-attributes-go-for-function-declaration

86.168.15.220 08:16, 25 July 2016 (PDT)


 * The function attributes can appear both after a declarator and before the declaration/definition, and also after the identifier within the declarator. Perhaps a mini-example would help, such as the Note from [dcl.dcl]/2. Example added. --Cubbi (talk) 08:27, 25 July 2016 (PDT)
 * oh, and you didn't get a response on StackOverflow because you didn't tag your question with c++ or c++11. Few people watch the tag "attributes" --Cubbi (talk) 08:50, 25 July 2016 (PDT)

Function types
I guess this article lacks paragpaph about function type declaration. E.g.  - is a valid function type, which may also be used with typedef. Also it may confuse. For example calling function which accepts std::string should be done as  or , but not Yanpas (talk) 13:53, 18 April 2017 (PDT)
 * type names are generally in cpp/language/type, which includes function types. This page is already too big. I suppose it could be worth making a mention that, as with any declaration, the type of the function declared as  is  with a link to Type_naming. The MVP (accidentally declaring a function as with , except that that one actually calls the function), is probably worth mentioning indeed. --Cubbi (talk) 14:03, 18 April 2017 (PDT)
 * added a write-up on MVP on cpp/language/direct_initialization (assuming someone trying to direct-init a variable will look there to find out what they got wrong) and added links from here to MVP and to type naming. --Cubbi (talk) 14:36, 18 April 2017 (PDT)

Clarify what 'outermost' mean
It states 'trailing return type is only allowed on the outermost function declarator'. It seems not clear that what 'outermost' mean here.

BTW: I test following code on my gcc 11, and it surprisingly compiles successfully. Is it a compiler extension or I just misunderstood 'outermost' here?

Yaossg (talk) 02:46, 10 September 2022 (PDT)


 * no, nested function declarator would be something like

..which also works. Don't know why I wrote "outermost". Maybe that you can't mix and match in the above case? I'll drop the word. --Cubbi (talk) 10:16, 11 September 2022 (PDT)

What is Declaring a function as defaulted after its first declaration
Under the section User-provided functions, it shows Declaring a function as defaulted after its first declaration can provide efficient execution and concise definition while enabling a stable binary interface to an evolving code base. I don't think that is correct. No matter what, `=default` and `=delete` is a function definition.--Sterben01 (talk) 19:25, 1 February 2023 (PST)


 * This is the original wording from [dcl.fct.def.default Note 1], and it is correct because a definition is always a declaration. There is no need to provide alternative wording because 'declaring a function as defaulted' can be interpreted as '= default;' with no difficulty or ambiguity. --Xmcgcg