From: Daniel Arndt Date: Mon, 24 Jan 2022 23:17:02 +0000 (-0500) Subject: Use standardized detection idiom X-Git-Tag: v9.4.0-rc1~563^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bf718672dac63c3472590d8f8bab16ed0f525b0;p=dealii.git Use standardized detection idiom --- diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index 6a253619b0..31c4fab041 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -27,6 +27,68 @@ DEAL_II_NAMESPACE_OPEN +template +using void_t = void; + +// Detection idiom from Version 2 of the C++ Extensions for Library +// Fundamentals, ISO/IEC TS 19568:2017 + +namespace internal +{ + // base class for nonesuch to inherit from so it is not an aggregate + struct nonesuch_base + {}; + + // primary template handles all types not supporting the archetypal Op + template + class Op, + class... /*Args*/> + struct detector + { + using value_t = std::false_type; + using type = Default; + }; + + // specialization recognizes and handles only types supporting Op + template class Op, class... Args> + struct detector>, Op, Args...> + { + using value_t = std::true_type; + using type = Op; + }; +} // namespace internal + +struct nonesuch : private internal::nonesuch_base +{ + ~nonesuch() = delete; + nonesuch(nonesuch const &) = delete; + void + operator=(nonesuch const &) = delete; +}; + +template class Op, class... Args> +using detected_or = internal::detector; + +template