相关疑难解决方法(0)

在C++标识符中使用下划线有哪些规则?

在C++中通常用某种前缀命名成员变量来表示它们是成员变量而不是局部变量或参数.如果你来自MFC背景,你可能会使用m_foo.我myFoo偶尔也见过.

C#(或者可能只是.NET)似乎建议只使用下划线,如_foo.这是否允许C++标准?

c++ standards naming-conventions c++-faq

906
推荐指数
4
解决办法
24万
查看次数


英特尔C++编译器编译递归decltype返回的速度非常慢

我正在为由任意数量的char标签参数化的表达式编写模板.

给定参数列表,工厂函数返回不同类型的表达式,具体取决于是否存在相同类型的两个参数或它们是否唯一.

一个具体的例子:假设这A是一个"可标记的"对象,其operator()重载生成一个?Expression<...>.我们a, b, ...将其声明为标签LabelName<'a'>, LabelName<'b'>, ....然后A(a,b,c,d)会产生一个UniqueExpression<'a','b','c','d'>,而反过来A(a,c,b,c)会产生一个RepeatedExpression<'a','c','b','c'>.

为了实现这一点,我不得不?Expressionauto和定义工厂函数decltype.此外,decltype必须级联到另一个,decltype直到元程序完成通过参数的递归并且最终决定返回类型.作为一个例子,我已经为工厂方法隔离了一个相当小的代码.

template <typename... T> struct TypeList { };
template <char C> struct LabelName { };

template <typename... T> class UniqueExpression
{
    // Contains implementation details in actual code
};

template <typename... T> class RepeatedExpression
{
    // Contains implementation details in actual code
}; …
Run Code Online (Sandbox Code Playgroud)

c++ icc decltype variadic-templates c++11

7
推荐指数
1
解决办法
1126
查看次数