Talk:Decltype
This is the talk page for discussing improvements to the Decltype article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This article is rated GA-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||||||||||||
|
Decltype has been listed as one of the Engineering and technology good articles under the good article criteria. If you can improve it further, please do so. If it no longer meets these criteria, you can reassess it. | |||||||||||||
| |||||||||||||
A fact from this article appeared on Wikipedia's Main Page in the "Did you know?" column on September 9, 2009. The text of the entry was: Did you know ... that decltype can be used to "clean up function syntax mess" in C++ programming? | |||||||||||||
Current status: Good article |
decltype and accidentally returning references to locals
[edit]There should be a section here on the problem of decltype causing functions to accidentally return references to temporaries. Example:
- template<typename T> auto f(bool b, T t, T u) -> decltype(b ? t : u) { return b ? t : u; }
Here, decltype(b ? t : u) will be T &, and this function will return a dangling reference. Does anyone have a citation for the appropriate critique? 74.125.122.49 (talk) 16:55, 5 January 2012 (UTC)
decltype and declval
[edit]No mention of declval within article. Nor does there exist a wiki page for same. — Preceding unsigned comment added by 46.65.52.44 (talk) 19:51, 5 November 2012 (UTC)
- That's because there is no such thing. — Preceding unsigned comment added by 192.35.35.35 (talk) 17:01, 31 May 2013 (UTC)
- Oh, but there is. It resides in the <utility> header (defined as template<typename T> typename std::add_rvalue_reference<T>::type declval() or similar). It seems no one has found the time to cover declval in this article, and it almost certainly doesn't warrant a stand-alone article. Regards,
decltype
(talk) 10:29, 4 June 2013 (UTC)
- Oh, but there is. It resides in the <utility> header (defined as template<typename T> typename std::add_rvalue_reference<T>::type declval() or similar). It seems no one has found the time to cover declval in this article, and it almost certainly doesn't warrant a stand-alone article. Regards,
Differences of decltype and auto, and decltype(auto)
[edit]It should be mentioned by some examples. And decltype(auto)
should be explained. --2A02:2028:2A7:C1B0:C89B:DE41:D2DA:146E (talk) 09:21, 25 August 2014 (UTC)
External links modified
[edit]Hello fellow Wikipedians,
I have just modified 2 external links on Decltype. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
- Added archive https://web.archive.org/web/20110708173703/http://docs.codegear.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devwin32/typespecifierdecltype_xml.html to http://docs.codegear.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devwin32/typespecifierdecltype_xml.html#
- Added archive https://web.archive.org/web/20110130065354/http://lists.cs.uiuc.edu:80/pipermail/cfe-dev/2011-January/013013.html to http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-January/013013.html
When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at {{Sourcecheck}}
).
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}}
(last update: 5 June 2024).
- If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
- If you found an error with any archives or the URLs themselves, you can fix them with this tool.
Cheers.—InternetArchiveBot (Report bug) 00:04, 10 December 2016 (UTC)
Misleading first sentence
[edit]The first sentence is a bit misleading:
- In the C++ programming language, decltype is a keyword used to query the type of an expression.
I suggest rephrasing along the lines of "... query the type of a variable declaration or expression, depending on the argument."
Beginners often get burned by the fact that C++ uses one keyword for two different purposes, so introducing the keyword as if it's possible to understand it as a single concept can compound the problem.
- GA-Class Computing articles
- Low-importance Computing articles
- All Computing articles
- GA-Class Computer science articles
- Low-importance Computer science articles
- WikiProject Computer science articles
- GA-Class C/C++ articles
- Low-importance C/C++ articles
- C++ articles
- WikiProject C/C++ articles
- Wikipedia good articles
- Engineering and technology good articles
- Wikipedia Did you know articles that are good articles