struct rgb_color {
constexpr rgb_color(std::uint8_t nr, std::uint8_t ng, std::uint8_t nb) :
r(nr), g(ng), b(nb) { }
std::uint8_t r; // red
std::uint8_t g; // green
std::uint8_t b; // blue
constexpr static rgb_color black = rgb_color(0, 0, 0);
constexpr static rgb_color white = rgb_color(255, 255, 255);
};
あります)、およびconstexpr
コンストラクタです。構造体が<code>constexpr static</code>定数定義をコンパイルすることができないタイプの非リテラル
なぜコードはコンパイルされませんか?
また、あなたはまだ完全に宣言されていないタイプをインスタンス化しているので、それが必要で、
constexpr rgb_color rgb_color::black;
constexpr static rgb_color black(0、0、0); 'を実行すると機能しますか? – Sean
いいえ:http://coliru.stacked-crooked.com/a/f7915407bb464659 – tmlen
リンクには「cv-qualified(C++ 17)」の候補があります。あなたのコンパイラはここではC++ 14のルールで動作しているかもしれません。 – MSalters