Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
根据给定的索引集获取参数包的子集
好吧 这确实是一件困难的事情 我希望能够通过在给定的一组有效索引处选择参数类型来获取参数包的子集 然后使用该参数包作为函数的参数列表 IE template
c
templates
parameters
variadictemplates
templatemetaprogramming
获取类中的字段数
有没有办法获取一个类的字段数量 struct Base char a int b struct Derived Base std string c static assert num fields value 2 static assert
c
C11
templates
templatemetaprogramming
typetraits
在编译时检测 typedef(模板元编程)
我目前正在做一些模板元编程 就我而言 我可以处理任何 可迭代 类型 即任何类型typedef foo const iterator以同样的方式存在 我试图为此使用新的 C 11 模板元编程 但是我找不到检测某种类型是否丢失的方法 因为我还需
c
C11
sfinae
templatemetaprogramming
typetraits
部分类型作为模板参数 c++ [重复]
这个问题在这里已经有答案了 简单地说 我可以通过吗std vector作为模板参数 以下示例列出用法 tempate
c
templates
templatemetaprogramming
不明确的元函数或未定义的类型
我是元功能的新手 我想编写一个函数 将复合类型中某种类型的所有匹配项替换为其他类型 在示例中 replace
c
boost
metaprogramming
templatemetaprogramming
boostmpl
使用 Lambda/Template/SFINAE 自动保护 Trampoline 函数的 try/catch
我有 100 个左右的蹦床函数 我想知道是否可以将每个都自动包装在 try catch 块中 请提前警告 这不是一个简单的问题 我将首先用 简化的 代码描述问题 然后尝试在下面尽力回答它 以便读者可以看到我所处的位置 Foo 有一个函数指针
c
C11
Lambda
templatemetaprogramming
trampolines
在编译时通过 constexpr 或模板函数获取多维 std::array 的大小
我用的是三维std array 因为大小在编译时已知 但是 我注意到 size 函数不是静态的 因此 constexpr 模板函数无法访问 我已经找到了下面的演示示例 它估计一维的大小std array 然而 这不适用于二维或更多维度 有没
c
C11
templates
templatemetaprogramming
constexpr
std::make_index_sequence 和 std::index_sequence 的详细信息
我很喜欢增加可变参数模板 并开始摆弄这个新功能 我正在尝试了解实施细节std index sequence s 用于元组实现 我在那里看到了示例代码 但我真的想要一个简单的逐步解释 说明如何std index sequence已编码 并且每
c
templates
c14
variadictemplates
templatemetaprogramming
编译时常量 id
鉴于以下情况 template
c
templates
templatemetaprogramming
编译时模板参数计算
我试图在编译时推断两个模板参数中较大的一个 两个模板参数的类型都是 size t 我有一个模板化类型 SomeType 它采用 size t 作为模板参数 然后 我有一个函数 它采用两个具有不同模板 size t 的 SomeType 参数
c
templates
templatemetaprogramming
使用 std::is_same 进行元编程
是否可以执行类似以下操作而无需模板专门化进行编译 template
c
templatemetaprogramming
C++ constexpr:在编译时计算 std 数组
我想转换一个 数组 bool到一个整数序列 所以我需要计算一个std array在编译时 这是我的代码 include
c
c14
variadictemplates
templatemetaprogramming
constexpr
如何在编译时捕获递归函数的结果?
include
templates
recursion
c14
templatemetaprogramming
constexpr
使用 Detected Idiom 实现 is_destructible
这是我的实现is destructible v https en cppreference com w cpp types is destructible template
c
languagelawyer
C17
templatemetaprogramming
typetraits
编译时生成的表
由于一些技巧 我能够在编译时生成一个表 但表中的值并不是很有用 例如 5x5 的表格如下所示 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 为了清楚起见 逗号的位置 创建该表的代码如下
c
templates
templatemetaprogramming
使用“std::enable_if_t”“函数模板已被定义”[重复]
这个问题在这里已经有答案了 我正在尝试使用std enable if t根据传递给模板函数的类型特征来切换模板函数的实现 这是一个例子 include
c
templates
C17
templatemetaprogramming
enableif
如何确定类型是否可以仅使用 const 引用进行调用?
我想写一个 C 元函数is callable
c
templates
C11
templatemetaprogramming
sfinae
一般对元组的每个元素调用成员函数
第一步 展开元组并将元素传递给函数 我有一个带有 N 个参数的函数 void func int double char 和一个具有匹配类型的元组 std tuple
c
templates
C11
templatemetaprogramming
stdtuple
模板元编程中三元运算符的替换
我正在 C 中实现二项式系数 n 选择 k 函数 除了使用 正常 函数 在运行时评估 之外 还可以使用模板元编程来完成 当参数在编译时已知时 template
c
templates
templatemetaprogramming
c03
如何定义一个变体
提取模板参数的子类型
我正在构建一个状态机 其中状态转换被描述为一种变体 即 using table std variant lt state event followup state transition
c
C17
templatemetaprogramming
statemachine
Variant
1
2
3
4
5
6
»