⬆️ ⬇️

C ++ 17 that we lost



On March 5, 2016, the next congress of the ISO C ++ committee in Jacksonville ended. People were going to pre-final to decide what will go in and what will not be included in the standard C ++ 17. Of course, not yet 2017th year, and something else may have changed. Nevertheless, it is believed that this particular event outlined C ++ 17 in its future form.



I will not be here to pull the cat by the tail and look for tolerant expressions: a catastrophe awaits us. The C ++ 11/14 standards were a very significant leap forward, but that was all. C ++ 17, promised once in a “major” release, in fact does not carry anything substantial in itself. A bit of syntactic sugar, a couple of little things in the standard library - and that's it. Echoes of this tragedy have already sounded to some echo on Habré, but I still decided to summarize the information and understand where we are going.





Let's start with the good.

')

What will be included in C ++ 17





File system

Great stuff! It would be if it entered the standard about 15 years ago. In fact, even in the ugly .NET classes for working with the file system - from version 1.1 (and this is 2003). And here we've got our hands on borrowing boost :: filesystem in 2016. Well, thanks for that.



any, optional, string_view

The first two pieces were already available in different libraries, string_view looks like a gag, for those who have not mastered constant links and shared_ptr. The third way to say "here's your line, which you do not own, you can only read it." Well, ok, it will look good in the interfaces, it will not give you any fundamental speed in comparison with the two previous methods.



Lambda constexpr-functions

constexpr int AddEleven(int n) {
return[n]{return n+11;}();
}
static_assert(AddEleven(5)==16,"");




, . , constexpr-, , , constexpr-. . . , , , .





, , - « ». , , , - — Threading Building Blocks, «Parallel STL», Intel Cilk Plus - . — . , , . « 14- 15-»





- ?! ? , ++ , ? , - , -, , , -, ++17?



ranged-for ,

(). — , . — , . , , - «, begin() ».



*this

. this , , . , .



[[fallthrough]], [[nodiscard]], [[maybe_unused]]

. , . , , .



.



++17







« ». « ». : « , ». , , - . - « typeclass », - , - , - . , .





! , -, . , ++17. , ( 2012- ) Clang Microsoft. , ( ), , . , , — . , ? , , , . : ++17 , , , « » ( ).





- . , , . , .

int f()
{
  static int i = 0;
  synchronized {
    printf("before %d\n", i);
    ++i;
    printf("after %d\n", i);
    return i;
  }
}






« ». , . Bjarne Stroustrup Herb Sutter. , ?





,

pair p(2, 4.5);




pair<int,double> p(2, 4.5); 




! « ». auto , , , — . ?



Networking

2016- , ++ . 2020- ! , , ? ++ - . ( , , . .)





, : habrahabr.ru/post/278267



( )

, :

auto function(ArgType1 arg1, ArgType2 arg2, ArgType3 arg3)
 [[ pre: arg1 != 0]]
 [[ pre: arg1 < arg2]]
 [[ pre: global_predicate(arg3) ]]
 [[ post: return > 0 ]]
 [[ post: other_predicate(return, arg1) ]]
 -> ResultType;




- , , . « true, false (?) ». . , ++17, , . !



constexpr if

. , , (. ).



Reflection

, ++ . :



, ++17. 20- 50/50.





++, , . , , , . ++11 . ISO C++. ++17 . , , , . , , — . 17- . - , Clang , , bleeding-edge 17- . ISO C++ , — . - , , . — . - ISO C++, , !

Source: https://habr.com/ru/post/279927/



All Articles