Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #68243
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Template argument deduction mystery |
| Date | 2019-09-05 21:50 +0000 |
| Organization | Netfront http://www.netfront.net/ |
| Message-ID | <qkrvui$22o2$1@adenine.netfront.net> (permalink) |
| References | <qkofo9$9mo$1@adenine.netfront.net> <qkpmsb$v9r$1@news.albasani.net> |
Bonita Montero <Bonita.Montero@gmail.com> wrote: >> std::sort(values, values+5, std::greater()); > > Doesn't work for me. > As I excpected VC++ as well as g++ require a template parameter. It appears that gcc has been slow to implement automatic template parameter deduction of this caliber. It only works from gcc 9 forwards. It doesn't work on previous versions of gcc. It does work on the current version of clang (I haven't tested which is the first version that added support). As for the answer to the question, I think I understand it now. std::greater is currently declared as template<typename T=void> struct greater; This means that the C++17 automatic template parameter deduction will make it std::greater<void> when no parameter is specified. std::greater<void> in turn has a specialization that has a templated operator(), which allows it to compare any types.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Template argument deduction mystery Juha Nieminen <nospam@thanks.invalid> - 2019-09-04 13:55 +0000
Re: Template argument deduction mystery Ian Collins <ian-news@hotmail.com> - 2019-09-05 07:16 +1200
Re: Template argument deduction mystery Bonita Montero <Bonita.Montero@gmail.com> - 2019-09-05 03:03 +0200
Re: Template argument deduction mystery Juha Nieminen <nospam@thanks.invalid> - 2019-09-05 21:50 +0000
Re: Template argument deduction mystery Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-09-05 20:04 -0400
Re: Template argument deduction mystery Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2019-09-06 14:55 +0100
Re: Template argument deduction mystery Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-09-06 23:56 -0400
Re: Template argument deduction mystery Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2019-09-07 15:25 +0100
Re: Template argument deduction mystery Juha Nieminen <nospam@thanks.invalid> - 2019-09-07 18:55 +0000
Re: Template argument deduction mystery Bo Persson <bo@bo-persson.se> - 2019-09-07 21:28 +0200
Re: Template argument deduction mystery Ian Collins <ian-news@hotmail.com> - 2019-09-08 12:29 +1200
Re: Template argument deduction mystery Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2019-09-07 23:06 +0100
Re: Template argument deduction mystery Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2019-09-07 18:35 -0400
csiph-web