What future C++ would look like

Here, Is the example of how the code that we could be able to write in future C++. Shown in cppcon2016. https://youtu.be/_wzc7a3McOs


import iostream
using namespace std;
module map_printer;

export
template<Sequence S>
void print_map(const S &m)
    requires Printable<keyType> && Printable<valueType<S>>; {


    for (const auto &[key,value]:m){
        cout<<key<<"->"<<value<<endl;
    }
}

This code has three features and we can use these features at present
also but At present, we can’t use these feature in combination with
each other like in above example.Instead, These can be used individually as these are provided by different compilers and not aprt of standard at present.
These features and provided by are:
1. modules ( by Microsoft compiler)
2. concepts ( by GCC 6.1)
3. structured binding ( by clang)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s