c++20

How to use c++20 modules with CMake?

我怕爱的太早我们不能终老 提交于 2020-12-25 01:41:40
问题 Clang and MSVC already supports Modules TS from unfinished C++20 standard. Can I build my modules based project with CMake or other build system and how? I tried build2, it supports modules and it works very well, but i have a question about it's dependency management (UPD: question is closed). 回答1: This works on Linux Manjaro (same as Arch), but should work on any Unix OS. Of course, you need to build with new clang (tested with clang-10). helloworld.cpp: export module helloworld; import

How to use c++20 modules with CMake?

≯℡__Kan透↙ 提交于 2020-12-25 01:41:17
问题 Clang and MSVC already supports Modules TS from unfinished C++20 standard. Can I build my modules based project with CMake or other build system and how? I tried build2, it supports modules and it works very well, but i have a question about it's dependency management (UPD: question is closed). 回答1: This works on Linux Manjaro (same as Arch), but should work on any Unix OS. Of course, you need to build with new clang (tested with clang-10). helloworld.cpp: export module helloworld; import

c++ auto for type and nontype templates

久未见 提交于 2020-12-14 11:55:36
问题 In c++17 template <auto> allows to declare templates with arbitrary type parameters. Partially inspired by this question, it would be useful to have an extension of template <auto> that captures both type and nontype template parameters, and also allows for a variadic version of it. Are there plans for such an extension in the next c++20 release? Is there some fundamental problem in having a syntax like template<auto... X> , with X any type or nontype template parameter? 回答1: Are there plans

c++ auto for type and nontype templates

折月煮酒 提交于 2020-12-14 11:44:07
问题 In c++17 template <auto> allows to declare templates with arbitrary type parameters. Partially inspired by this question, it would be useful to have an extension of template <auto> that captures both type and nontype template parameters, and also allows for a variadic version of it. Are there plans for such an extension in the next c++20 release? Is there some fundamental problem in having a syntax like template<auto... X> , with X any type or nontype template parameter? 回答1: Are there plans

c++ auto for type and nontype templates

梦想的初衷 提交于 2020-12-14 11:42:24
问题 In c++17 template <auto> allows to declare templates with arbitrary type parameters. Partially inspired by this question, it would be useful to have an extension of template <auto> that captures both type and nontype template parameters, and also allows for a variadic version of it. Are there plans for such an extension in the next c++20 release? Is there some fundamental problem in having a syntax like template<auto... X> , with X any type or nontype template parameter? 回答1: Are there plans

C++20 #import “”-statement: Will it be possible to use multiple preprocessed header files

做~自己de王妃 提交于 2020-12-13 03:35:55
问题 In C++20 it is possible to instead of include headers with #include "header.h" use #import "header.h" // Edit: this is not standard see comments (this is for old code that cannot fully be converted to modules and use the normal import keyword without #) My question is about preprocessing. For a long time it as only been possible to precompile and use one header per translation unit. (Clang seems to have some special case with cascading include files, that I do not consider here) Will it be

How to include multiple precompiled headers in with c++20 (with modules enabled) in gcc or clang

China☆狼群 提交于 2020-12-12 05:39:51
问题 In c++20, when enabling modules, each include is supposed to be encapsulated so that the ordering does not matter, and macros does not leak out etc. Apparently the question if it is possible to precompile multiple headers is yes. My question now is: How do you do this: That is: How do i first precompile a set of headers and then make the compiler recognize them (all of them) as precompiled headers for my translation unit using c++20 modules, (using linux command line). I would like to have

Why have comparison operators been removed from standard library containers in C++ 20?

Deadly 提交于 2020-12-02 06:58:48
问题 I was browsing cppreference and saw that vector 's comparison operations have been removed in C++20, and the spaceship operator ( <=> ) has been introduced. The same thing can be seen for many other standard library containers like set and map. How do I do the comparisons in the new standard? Also, will C++20 start giving errors on older code? 回答1: If you continue to browse on the reference site a little, you might come to the section on default comparisons, which simply states that: In brief

Why have comparison operators been removed from standard library containers in C++ 20?

拜拜、爱过 提交于 2020-12-02 06:58:11
问题 I was browsing cppreference and saw that vector 's comparison operations have been removed in C++20, and the spaceship operator ( <=> ) has been introduced. The same thing can be seen for many other standard library containers like set and map. How do I do the comparisons in the new standard? Also, will C++20 start giving errors on older code? 回答1: If you continue to browse on the reference site a little, you might come to the section on default comparisons, which simply states that: In brief

What is the need of template lambda introduced in C++20 when C++14 already has generic lambda?

泄露秘密 提交于 2020-11-30 04:22:42
问题 c++14 introduced generic lambdas that made it possible to write following: auto func = [](auto a, auto b){ return a + b; }; auto Foo = func(2, 5); auto Bar = func("hello", "world"); It is very clear that this generic lambda func works just like a templated function func would work. Why did the C++ committee decide to add template syntax for generic lamda? 回答1: C++14 generic lambdas are a very cool way to generate a functor with an operator () that looks like this: template <class T, class U>