Let's say I have a templatized function that is going to be specialized, so I really don't care about the base implementation. Can I do something like this:
template <typename T>
T dummy() {
assert(false);
return declval<T>();
}
When I try to do this in visual-studio-2017 I get a linking error:
unresolved external symbol
char const && __cdecl std::declval<char const >(void)
(??$declval@$$CBD@std@@YA$$QEBDXZ) referenced in functionchar const __cdecl dummy<char const>()
Again this function is uncalled, but I do save a pointer to it. I can use return T{}
instead, and that compiles, but I need this to work even if there isn't a default constructor for T
. Is there a way that I can work around this?