Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 有机会使用标准库吗#包括<;概念>;叮当作响_C++_C++ Concepts - Fatal编程技术网

C++ 有机会使用标准库吗#包括<;概念>;叮当作响

C++ 有机会使用标准库吗#包括<;概念>;叮当作响,c++,c++-concepts,C++,C++ Concepts,现在有一个叫“叮当”的版本 “x86-64 clang(实验性概念)”,提供实验性核心语言概念功能 是否还有一种方法可以使用标准库实现(实验版本) 在设计概念时,如果有std::convertible_to和朋友,那就太好了 在我看来,GCC在实现C++20特性方面更为领先。以下代码使用GCC(trunk)运行: #包括 #包括 模板概念标量=std::is_scalar_v; 模板 福班 { 公众: Foo(tt)需要标量:_T{T}{std::cout #include <iostre

现在有一个叫“叮当”的版本 “x86-64 clang(实验性概念)”,提供实验性核心语言概念功能

是否还有一种方法可以使用标准库实现(实验版本)


在设计概念时,如果有
std::convertible_to
和朋友,那就太好了

在我看来,GCC在实现C++20特性方面更为领先。以下代码使用GCC(trunk)运行:

#包括
#包括
模板概念标量=std::is_scalar_v;
模板
福班
{
公众:
Foo(tt)需要标量:_T{T}{std::cout
#include <iostream>
#include <concepts>

template<typename T> concept scalar = std::is_scalar_v<T>;

template<typename T>
class Foo
{
public:
    Foo(T t) requires scalar<T>: _t{t} { std::cout << "is scalar" <<std::endl; }
    Foo(T t) requires (not scalar<T>): _t{t} { std::cout << "is not scalar" <<std::endl;}
private:
    T _t;
};

class cls {};

int main() 
{
    Foo{true};
    Foo{'d'};
    Foo{3.14159};
    cls c;
    Foo{c};

    return 0;
}