I implemented std::experimental::is_detected
based on this article on cppreference.com (Part of the code is below + working repro).
It works well on G++
Here's a workaround that appears to work with recent MSVC (tested with Visual C++ 19.00.23720.0):
#include
template
using void_t = void;
namespace internal
{
template
struct detect_impl
{
using value_t = V;
using type = D;
};
template class Check, typename... Args>
auto detect_check(char)
-> detect_impl;
template class Check, typename... Args>
auto detect_check(int)
-> decltype(void_t>(),
detect_impl>{});
template class Check, typename... Args>
struct detect : decltype(detect_check(0)) {};
}
struct nonesuch
{
nonesuch() = delete;
~nonesuch() = delete;
nonesuch(nonesuch const&) = delete;
void operator=(nonesuch const&) = delete;
};
template class Check, typename... Args>
using is_detected = typename internal::detect::value_t;
(The dummy void
parameter is unused now, it's there just to keep the rest of the implementation intact.)