考虑一个static constexpr
成员的这种使用情况:将静态const成员重新声明为constexpr会自动使其成为内联吗?
// smart_enum.h
class smart_enum {
// Some data, operations, etc.
// Cannot use constexpr here, smart_enum is incomplete at this point
static const smart_enum first, second;
};
constexpr smart_enum smart_enum::first = {}, smart_enum::second = {};
是first
和second
自动inline
变量?还是我需要对其进行限定?或者我无法将它们限定为内联,并且稍后需要在某个源文件中提供定义?我一直很困惑,从const
到constexpr
这个“重新定义”,并希望更多的光芒流失这意味着什么。
具体来说,我想知道关于const
声明constexpr
定义,以及如何与一个static constexpr
(Redefinitions of constexpr static data members are allowed now? (but not inline const)?)
“此外,constexpr说明符暗示静态数据成员以及函数的内联。” - 但是我想把这个constexpr放在课堂上。 – lorro
@lorro,但你不能把它放在课堂上,这是我的困惑所在。 – user975989