I am learning C++ using the books listed here. In particular, I learnt that we cannot use std::string
as a non-type template parameter. Now, to further clear my concept of the subject I tried the following example which compiles in gcc and msvc but not in clang. Demo
std::string nameOk[] = {"name1", "name2"};
template<std::string &name>
void foo()
{
}
int main()
{
foo<nameOk[0]>(); //this compiles in gcc and msvc but not in clang in C++20
}
My question is which compiler is right here(if any). That is, is the program well-formed or IFNDR.