C++17 引入了各种辅助变量模板,例如,
template< class T, class U >
inline constexpr bool is_same_v = is_same<T, U>::value;
template< class T >
inline constexpr bool is_aggregate_v = is_aggregate<T>::value;
它们都被标记了inline
。由于constexpr
默认情况下暗示内部链接 [ ref ],即使没有inline
,也不会违反单一定义规则。所以我认为这里没有inline
必要。我也看不到它带来的任何好处。那为什么inline
?