⬆️ ⬇️

C ++ 20 is getting closer. Meeting in jacksonville

In early March, the meeting of the WG21 international working group on C ++ standardization ended in the American city of Jacksonville. At the meeting, chips were added in C ++ 20, prepared for the release of a “preview” of new components and polished to a gloss of tongue roughness.



Want to look at the news and find out:





Calendars and time zones



See how beautiful and easy you can now set dates in C ++ 20:



using std::chrono;
year_month_day ymd = 2016y/May/29d; // 2016-05-29


, ? :



auto tp = sys_days{ymd} + 7h + 30min + 6s + 153ms; // 2016-05-29 07:30:06.153 UTC
zoned_time zt = {"Asia/Tokyo", tp};
cout << zt << '\n';                                          // 2016-05-29 16:30:06.153 JST


, , « », « » « ». ..



4000 :



auto last_friday_feb = February/Friday[last];
std::cout << 4000 / last_friday_feb << std::endl;


.



Span



std::string_view C++17 ( boost::string_view/boost::string_ref), std::span !



, , - int:



void do_something(int* p, size_t size);


:



std::vector<int> v;
do_something(v.data(), v.size());

int data[1024];
do_something(data, std::size(data));

boost::container::small_vector<int, 32> sm;
do_something(sm.data(), sm.size());


— + range based for:



void do_something(int* p, size_t size) {
    std::sort(p, p + size);
    for (size_t i = 0; i < size; ++i) {
        p[i] += p[0];
    }
}


, std::span — , ( , , ). :



void do_something(std::span<int> p) {
    std2::sort(p);
    for (int& v: p) {
        v += p[0];
    }
}
// ...
std::vector<int> v;
do_something(v);

int data[1024];
do_something(data);

boost::container::small_vector<int, 32> sm;
do_something(sm);


std::span pdf.



typename? C++20!



, typename, – , ! C++20 typename:




template<class T> T::R f();

template<class T> struct S {
    using Ptr = PtrTraits<T>::Ptr;

    T::R f(T::P p) {
        return static_cast<T::R>(p);
    }

    auto g() -> S<T*>::Ptr;
};








onstexpr



– std::allocator constexpr . , – C++20 std::vector std::string, . , , .



, . , , 21 «constexpr iterator», , . constexpr .



, , , Herb Sutter “Meta: Thoughts on generative C++”.





«Parallelism 2 TS». , , SIMD , . (SSE, AVX, NEON, MDMX ..):



void compute_on_aligned_data(float* data, size_t N) {
    size_t i = 0;
    for (; i + native_simd<float>::size() <= N; i += native_simd<float>::size()) {
        native_simd<float> v(data + i, vector_aligned);
        where(v > 100.f, v) = 100.f + (v - 100.f) * 0.1f;
        v.copy_to(data + i, vector_aligned);
    }

    for (; i < N; ++i) {
        float x = data[i];
        if (x > 100.f) {
            x = 100.f + (x - 100.f) * 0.1f;
        }
        data[i] = x;
    }
}


SIMD .



( fork based , , ..) .





.





, promise. , . , , :



future​<std::string>​ ​concat​(const​ std::string​& ​ prefix​, future​<std::string>​ suffix​) {
    co_return ​ (prefix ​ + ​ co_await suffix​);
}




, . . , .



Reflection TS



TS . . .





, C++, .



C++. , WG21, .



. C++ . Houdini, , C++ C++11.





. - C++ , https://stdcpp.ru/, 21 .



? C++ Russia .



C++ ? , memory_order_relaxed memory_order_seq_cst.



, C++20 .


')

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



All Articles