c++-concepts专题提供c++-concepts的最新资讯内容,帮你更好的了解c++-concepts。
考虑以下代码: <pre><code>#include &lt;iostream&gt; constexpr int fun(int const&amp;) { return 5; } struct T { int x; }; int
在 C++20 中,我使用非类型模板参数包 <code>AllIntegral</code> 定义了一个概念 <code>auto... T_values</code>。 虽然
我正在尝试为类型名称 <code>int</code> 编写一个概念,但找不到。我想不出任何仅对 <code>int</code> 类型有
有人知道下面的不一致吗?其中 <strong>gcc</strong> 和 <strong>clang</strong> 在涉及 <strong>c++20 概念</strong> 时表
抱歉,标题含糊不清,我找不到合适的词来形容它。 我试图强制一个类定义一些函数/运算符是正确的。
我正在尝试使用 C++20 概念实现一个递归版本 <a href="https://en.cppreference.com/w/cpp/types/result_of" rel="nofollow nore
<code>using T = decltype(std::same_as&lt;int, double&gt;)</code> 我在 VS2019 上试过这个。事实证明,<code>T = bool</code>.</p
假设我想为所有类型实现 <code>operator&lt;&lt;</code>。我会这样做: <pre><code>template &lt;typename T&gt; std::ostr
我决定全力以赴,在我正在启动的库中使用 C++ 20 的概念。 我已经在 GCC 主干上测试了以下代码并
我想抽象类型接口,但我很难在概念的两种 C++ 方法和 type_traits 之间做出决定。考虑以下场景: <pre c
我想测试 c++20 中的新概念功能,我想知道是否可以创建一个概念来检查声明为 const 的函数是否存在。<br
这两段示例代码做同样的工作,对我来说都很有意义。那么什么时候应该使用概念,什么时候使用接口
尝试实现<a href="https://godbolt.org/z/zPMae4" rel="nofollow noreferrer">the following code</a>: <pre><code>template &lt;typena
我正在尝试使用概念来检测给定类型的 begin 函数是否将迭代器返回到“const T&”或仅返回到“T&”。但我
我正在尝试定义部分专门化的类模板的成员函数,但不同的编译器对我可以做什么以及为什么有截然不
<h1>背景</h1> 根据<a href="https://timsong-cpp.github.io/cppwp/temp.arg.template#1" rel="nofollow noreferrer">[temp.arg.template]/1</
我想写一个类模板,它: <ul> <li><code>A&lt;float&gt;</code> 只有一个成员变量 <code>val</code>;</li> <li><code>A&lt
考虑这个小代码片段 <pre><code>namespace nsp { template&lt;typename T&gt; concept Addable= requires(const T&amp; a,co
比如说我有一个函数 <code>foo()</code> 带有一个参数包 <code>Ts</code>。然而,如果只有一种类型满足 <code>Ts</
给定一个这样的类模板: <pre class="lang-cpp prettyprint-override"><code>template&lt;typename T&gt; struct foo { T data