Is it valid C++ to do a template specialization of a function inside an inline namespace in the space outside the inline namespace?
For example, would this compile?
namespace A
{
inline namespace A0
{
namespace B
{
template<typename T>
T sum(T v1, T v2)
{
return v1 + v2;
}
}
}
}
namespace A
{
namespace B
{
template<>
float sum<float>(float v1, float v2)
{
return v1 - v2; // Do something different
}
}
}
Currently, this code compiles with g++ 13.02, but not with MSVC 19.40 for c++17
New contributor
Edwin Lester Solis Fuentes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2