Does std::integral_constant<T, v>::value always have a definition?

Bri*_*ian 6 c++ c++14

In the C++14 standard, the std::integral_constant template is defined as follows:

template <class T, T v>
struct integral_constant {
  static constexpr T value = v;
  typedef T value_type;
  typedef integral_constant<T,v> type;
  constexpr operator value_type() const noexcept { return value; }
  constexpr value_type operator()() const noexcept { return value; }
};
Run Code Online (Sandbox Code Playgroud)

It doesn't say whether there's a corresponding out-of-line definition for the static data member, i.e.,

template <class T, T v>
constexpr T integral_constant<T, v>::value;
Run Code Online (Sandbox Code Playgroud)

I looked through the standard for a requirement that such a definition be provided, but couldn't find one, so I don't know whether portable code may odr-use value.

(In C++17, static constexpr members became implicitly inline, making the in-class declaration a definition.)

Nic*_*las 4

[contents]/1中的一揽子声明涵盖了这一点,该声明定义了标准库实现的一般规则:

C++ 标准库提供以下类型实体的定义:宏、值、类型、模板、类、函数、对象。

非引用类型的变量是对象,所以value这里是一个对象。因此,标准库必须为其提供定义。

这个声明的 C++17 版本在这个问题上更加直接:

C++ 标准库提供了 C++ 标准库标头概要中描述的实体和宏的定义。

value肯定是一个实体,它在 C++ 标准库头文件的概要中进行了描述。因此,必须给出一个定义。