相关疑难解决方法(0)

在struct中初始化静态constexpr变量和类

这是我的工作代码示例:

#include <iostream>

template<typename B>
class b {
public:
    int y;

    constexpr b(int x) : y(x) {

    }

    constexpr void sayhi() {
        std::cout << "hi" << std::endl;
    }
};



template<int x>
struct A {
    static constexpr b<int> bee = x;
    static constexpr int y = x;         // this one is fine and usable already, I don't have to do something like what I did on member bee

    inline static void sayhi() {
        std::cout << y << std::endl;
    }
};

template<int …
Run Code Online (Sandbox Code Playgroud)

c++ struct constexpr

11
推荐指数
2
解决办法
1万
查看次数

标签 统计

c++ ×1

constexpr ×1

struct ×1