// Copyright (c) 2023, QuantStack and Mamba Contributors // // Distributed under the terms of the BSD 3-Clause License. // // The full license is in the file LICENSE, distributed with this software. #ifndef MAMBA_UTIL_TYPE_TRAITS_HPP #define MAMBA_UTIL_TYPE_TRAITS_HPP #include #include namespace mamba::util { namespace detail { /** * Simple detection idiom from N4502 proposal. * * Primary template handles all types not supporting the operation. * * @see https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf */ template typename, typename = std::void_t<>> struct detect : std::false_type { }; /** * Specialization recognizes/validates only types supporting the archetype. */ template typename Op> struct detect>> : std::true_type { }; template using left_shift_operator_t = decltype(std::declval() << std::declval()); template using ostreamable_t = left_shift_operator_t; } template using is_ostreamable = detail::detect, detail::ostreamable_t>; template inline constexpr bool is_ostreamable_v = is_ostreamable::value; template inline constexpr bool is_any_of_v = std::disjunction_v...>; } #endif