Consider this code (godbolt):
#include <type_traits>
#include <memory>
#include <cstdlib>
using namespace std;
template<auto L, class T = decltype(L)>
using constant = integral_constant<T, L>;
int main()
{
unique_ptr<void, constant<&free>> p1;
unique_ptr<void, constant<free>> p2; // <-- MSVC refuses to compile this line
return 0;
}
Why does MSVC refuse to compile the highlighted line? Is this code valid?
MSVC produces:
<source>(13): error C2975: 'L': invalid template argument for 'constant', expected compile-time constant expression
<source>(7): note: see declaration of 'L'