constexpr

    4热度

    1回答

    下面的代码在GCC(4.9.3)和VC++(19.00.23506)中编译得很好,但在Clang( 3.7.0)。 error: constexpr function's return type 'Foo' is not a literal type note: 'Foo' is not literal because it is not an aggregate and has no const

    2热度

    1回答

    我赶上试图与consexpr装饰时错误“constexpr功能......不是回归语句的身体”: $ g++ -std=c++11 test.cxx -o test.exe test.cxx: In instantiation of ‘static constexpr unsigned int MinMaxStep<min, max , step>::ValidValue(unsigned i

    1热度

    1回答

    我试图与constexpr和static_assert一起玩。实际上我需要检查一个constexpr字符串的长度,它是由一个专用函数计算的。这里就是我试图运行: #include <iostream> using namespace std; class Test { private : static constexpr char str[] = "abc";

    2热度

    1回答

    进行评估编译时间上下文像模板参数ot enum shenanigans)? 事情是这样的: const int a = force_compute_at_compile_time(omg()); 也许这样的事情(不编译 - 我没有太多成constexpr尚): template<typename T> constexpr T force_compute_at_compile_time(cons

    10热度

    1回答

    假设我有一个constexpr函数指针数组,我想编写一个constexpr函数来查找指定函数的数组索引。 我可能有这样的代码: void test1(){}void test2(){}void test3(){}void test4(){} typedef void(*func)(void); constexpr func funcs[] = { &test1, &test2, &test3

    2热度

    2回答

    按照[dcl.constexpr/3]: 一个constexpr函数应满足下列要求的定义: [...] - 其功能体应为=删除,=默认情况下,或[。 .. 这意味着下面的类代码段是有效的: struct S { constexpr void f() = delete; }; 删除constexpr函数的目的是什么? 定义它有什么好处constexpr如果有的话? 我找不出任何理由,

    5热度

    1回答

    我正在实现一些非常类似于std::vector的东西,但在堆栈上使用数组而不是内存分配。 d-tor调用一个使用SFINAE的函数。 如果value_type是POD功能有空体。 如果value_type是普通类std::string,则该函数具有正文并正确销毁所有数据。 现在,我希望能够使用这个新的std::vector作为constexpr。然而即使C-tor被宣布为constexpr,代码也

    0热度

    1回答

    我是新来的,所以。这可能是基本的东西...我有问题与IE浏览器,它不呈现网页铬和FF。这三个盒子,boxleft,boxcenter和boxright odes并不排列。最后一个,box out似乎就像在boxcenter下面一样落下。我试图找到答案,但没有运气。这里是html和css。任何形式的帮助都是非常受欢迎的。谢谢。 <!DOCTYPE html> <html> <head>

    4热度

    2回答

    我有一个模板功能,并在一个点上,我想这取决于模板参数有不同的代码: template <typename T> void function(const T ¶m) { // generic code here... // pseudo-code: if constexpr isinstance(param, Banana) { param.pe

    2热度

    2回答

    我想弄清楚使用constexpr和preprocessor macro定义整数和字符串文字之间的“底层”差异。 #define FIRST_STRING "first_stringer" constexpr char second_string[] = "second_stringer"; #define FIRST_INT 1234 constexpr int second_int =