youtube: C++17 - The Best Features - Nicolai Josuttis [ACCU 2018]
笔记:
在头文件中定义静态变量 inline static
class TrackNew{
private:
inline static int numMalloc=0;
}
C++17 compile-TIme if
template<typename T>
st::string asString(T x)
{
if constexpr(std::is_arithmetic_v<T>){
return std::to_string(x);
}
else if constexpr(std::is_same_v<T,std::string>){
return x;
}
else {
return std::string(x);
}
}
std::cout<<asString(42)<<'\n';
std::cout<<asString(std::string("hello"))<<'\n';
std::cout<<asString("hell")<<'\n';
std::variant, std::visit
#include <execution>
std::execution::par,
parallel STL.