Namespaces
Variants
Views
Actions

std::experimental::nonesuch

From cppreference.com
Defined in header <experimental/type_traits>
struct nonesuch {

    nonesuch() = delete;
    ~nonesuch() = delete;
    nonesuch(nonesuch const&) = delete;
    void operator=(nonesuch const&) = delete;

};
(library fundamentals TS v2)

std::experimental::nonesuch is a class type used by std::experimental::detected_t to indicate detection failure.

[edit] Notes

nonesuch cannot be constructed, destroyed, or copied in the usual way. However, it is an aggregate and therefore can be constructed (presumably unintentionally) via aggregate initialization in contexts where the destructor's availability is not an issue, such as a new-expression: new std::experimental::nonesuch{}.

Additionally, for overload resolution purposes, an implicit conversion sequence can be formed from {} (an empty braced-init-list) to nonesuch. This can cause surprising ambiguities:

struct such {};
void f(const such&);
void f(const std::experimental::nonesuch&);
f({}); // ambiguous