Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
如何构建一个在用作 constexpr(如断言)时行为不同的自定义宏?
从 C 14 开始 断言宏可以在函数中使用 即使它们被定义为 constexpr 我知道这与它的计算结果为 true 有关 但我无法弄清楚实际的代码是什么样子 具体来说 如何构建一个宏 该宏在运行时评估的 constexpr 函数中运行时打
c
macros
c14
assert
constexpr
存储各种类型对象之间的许多 1:1 关系:解耦和高性能
我有 300 多个课程 它们在某些方面是相关的 为简单起见 所有关系均为 1 1 这是一个示例图 In real case there are around 50 relation pairs Note 对于某些情况 某些关系可能不存在 例
c
database
c14
relationship
onetoone
引用声明是否为引用对象引入了新名称?
In 这个问题 https stackoverflow com q 33344259 560648我们知道 RVO 不能应用于像这样的表达式p first 在评论中还建议 RVO 通常不适用于类似这样的表达式r在声明之后auto r p f
c
C11
languagelawyer
c14
c03
C++ constexpr:在编译时计算 std 数组
我想转换一个 数组 bool到一个整数序列 所以我需要计算一个std array在编译时 这是我的代码 include
c
c14
variadictemplates
templatemetaprogramming
constexpr
在 emplace() 内创建对象时复制省略
我在工作中看到很多代码 人们将 emplace 和 emplace back 与临时对象一起使用 如下所示 struct A A A int int vector a v vector a emplace back A 1 2 我知道 em
c
c14
copyelision
如何在编译时捕获递归函数的结果?
include
templates
recursion
c14
templatemetaprogramming
constexpr
将相同的运算符专门用于不同的特征
我想通过特征进行专业化来执行以下操作 Array Aa Scalar in a会使用overload I Array Aa Array Bb会使用overload II 在下面的代码中 overload II永远不会习惯 有人提到过T1不能
c
c14
templatespecialization
typetraits
C++14 与 C++17 的部分专业化差异?
代码 include
c
templates
c14
C17
partialspecialization
调用基类构造函数而不命名其类
class MyDerived public Incredble
c
C11
c14
在结构数组 (AoS) 和数组结构 (SoA) 之间来回切换
在许多面向数据设计的著作中扮演着重要角色的一个特征是 在许多情况下 而不是 AoS 结构数组 struct C AoS int foo double bar std vector
c
C11
c14
dataorienteddesign
constexpr 函数内的编译时或运行时检测
当 C 11 中引入 constexpr 时 我很兴奋 但不幸的是我对其有用性做出了乐观的假设 我假设我们可以在任何地方使用 constexpr 来捕获文字编译时常量或文字编译时常量的任何 constexpr 结果 包括如下所示 const
c
c14
constexpr
compiletime
C17
为派生类专门化 std::hash 在 gcc 中有效,而不是 clang
我正在努力专攻std hash对于派生类 迄今为止最好的方法是基于这个答案 https stackoverflow com a 31213703 620382 include
c
gcc
Clang
c14
sfinae
switch 语句条件中同时具有模板和非模板转换运算符的类
问题最初出现在这个问题 https stackoverflow com questions 25046418 internal compiler error templated conversion operator in switch e
c
C11
languagelawyer
implicitconversion
c14
即使我指定了 -std=c++14 __cplusplus < 201402L 在 gcc 中也会返回 true
该指令 ifndef cplusplus error C is required elif cplusplus lt 201402L error C 14 is required endif 命令行 g Wall Wextra std c
c
gcc
g
c14
predefinedmacro
用户定义类型的 std::common_type 特征
自 C 11 起 类型特征std common type被介绍了 std common type确定其所有模板参数之间的公共类型 在 C 14 中它的辅助类型std common type t还被引入是为了制作使用的代码std common
c
templates
C11
c14
typetraits
在 C++14 中推导“auto”之前使用“auto func(int)”
我使用 GCC 编译了以下程序C 14 include
c
function
gcc
c14
AUTO
Eric Niebler 的 std::is_function 实现是如何工作的?
上周埃里克 尼伯勒tweeted https twitter com ericniebler status 852192542653329408一个非常紧凑的实现std is function http en cppreference co
c
C11
templates
c14
typetraits
链接器错误,静态常量似乎没有被 odr 使用
当您了解细节时 odr used 标准中的定义非常令人困惑 至少对我来说是这样 我通常依赖 如果引用 的非正式定义 except当左值到右值的转换可用时 对于整型常量 它们应该被视为右值 这似乎应该将其排除在引用规则之外 这是我无法链接的示
c
c14
onedefinitionrule
模板参数包如何可以有其他尾随参数?
在C 14标准草案中 温度参数 11 https timsong cpp github io cppwp n4140 temp param 11 says 如果主类模板或别名模板的模板参数 是一个模板参数包 它应该是最后一个模板参数 如果您
c
templates
c14
variadic
绑定元函数:接受类型和模板模板参数(接受任何内容)
我正在尝试写一个Bind将模板参数绑定到某些内容的元编程模板帮助器元函数 我有一个简单模板元函数的工作实现 template
c
templates
metaprogramming
c14
templatetemplates
«
1
2
3
4
5
6
7
8
...20
»