5 ms·
What are the big new features of C++17? C++11 seemed like the last big change - I think the only reason I bother using "-std=c++14" is for "make_unique".
by lacampbell 10y ago
What are the big new features of C++17? C++11 seemed like the last big change - I think the only reason I bother using "-std=c++14" is for "make_unique".
- gpderetta 10y agoThe major user visible features of C++14 were polymorphic lambdas, generalized lambda capture, proper constexpr, member initializers and return type deduction. I use most of these everyday. For C++17 the biggest features are structured binding, which is the first step toward pattern matching, and deduction of template parameters for class types. Other features like fold expressions are realy meant for library writers. The standard library did get variant and optional whixh arw pretty cool.
- ot 10y agoThe lack of generalized lambda capture was one of the biggest idiosyncrasies of C++11, given its focus on move semantics.
- gpderetta 10y agoEven in with the last draft it still not possible to easily move-capture a variadic parameter pack; it is a fairly esoteric feature and there are workarounds, but it is still annoying.
- 72deluxe 10y agoOh how I envy your use of C++14 every day. Here we are still trying to migrate off VC2008 and C++2003. Variant and optional would be really useful if only I could use them. One day, one day... (ps doesn't stop me writing using these new features at home on other projects)
- c_shu 10y agoPlease always use "-std=c++14" when you can. There are a lot of subtle differences between c++11 and c++14.
- delhanty 10y agoOff-topic (apologies): From Xcode, I have the choice between "-std=c++14" and "-std=gnu++14" and I am not sure which I should choose ...
- Ralith 10y agoDo you want GNU extensions? Use the latter. Otherwise, use the former.
- CJefferson 10y agoGnu++14. This is because historically GCC / clang used gnu++03, so some libraries might require it. The gnu bit means "add as small number of extensions". None of them are that strange.
- kryptiskt 10y agoUse "-std=c++14" unless you need the gnu extensions for it to build, that ensures that you don't accidentally introduce non-portable code.
- nullc 10y agoThat is a nightmare fuel comment-- are people's valid C++11 codebases going to execute in materially different ways when someone flips the std flag to c++14?
- c_shu 10y agoYou have a point. Some people still write C++03 code because "My code will mostly work fine when I flip flag to C++11 anyway". But I always hope newer standards prevail, and make C++ great again.
- adrianN 10y agoAnd the people who program most of the stuff you can touch with your hands mostly still write c++-kinda-98 because "My compiler doesn't have a flag to flip to C++11 anyway" :(
- claudius 10y agoPersonally, I am really looking forward to constexpr if, i.e. if branches which are discarded at compile time and only have to be syntactically but not semantically correct. This should help a lot in avoiding enable_if magic to select the correct template.