According to this answer constexpr function are always inline
.
A template function can be declared constexpr
even if all specialization does not fulfill the requirements to be a constexpr
function. In this last case, the specialization is not constexpr
.
For example:
template<class T>
constexpr decltype(auto) size(const T& a){
return a.size();
}
std::array<int,10> arr;
std::vector<int> vec;
size(arr);//constexpr
size(vec);//not a constexpr;
The instantiation size<std::vector>
is not constexpr
, but is it inline
?