As a workaround for a normal template function, you can do:
template<typename T> constexpr auto gun();
template<>
constexpr auto gun<void>() {}
Following the same logic, I think the following should not change your original code too much:
#include <type_traits>
#include <utility>
struct X
{
constexpr auto gun() {}
};
template<class T>
struct Y
{
constexpr auto gun();
};
template<>
constexpr auto Y<X>::gun() { }
int main()
{
static_assert(std::is_same<void, decltype(std::declval<Y<X>>().gun())>::value, "");
}
Also as already stated, an empty return
statement will do the trick.
constexpr auto gun() {return;}