File indexing completed on 2025-01-18 09:38:12
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_HISTOGRAM_DETAIL_STATIC_IF_HPP
0008 #define BOOST_HISTOGRAM_DETAIL_STATIC_IF_HPP
0009
0010 #include <type_traits>
0011 #include <utility>
0012
0013 namespace boost {
0014 namespace histogram {
0015 namespace detail {
0016
0017 template <class T, class F, class... Args>
0018 constexpr decltype(auto) static_if_impl(
0019 std::true_type, T&& t, F&&,
0020 Args&&... args) noexcept(noexcept(std::declval<T>()(std::declval<Args>()...))) {
0021 return std::forward<T>(t)(std::forward<Args>(args)...);
0022 }
0023
0024 template <class T, class F, class... Args>
0025 constexpr decltype(auto) static_if_impl(
0026 std::false_type, T&&, F&& f,
0027 Args&&... args) noexcept(noexcept(std::declval<F>()(std::declval<Args>()...))) {
0028 return std::forward<F>(f)(std::forward<Args>(args)...);
0029 }
0030
0031 template <bool B, class... Ts>
0032 constexpr decltype(auto) static_if_c(Ts&&... ts) noexcept(
0033 noexcept(static_if_impl(std::integral_constant<bool, B>{}, std::declval<Ts>()...))) {
0034 return static_if_impl(std::integral_constant<bool, B>{}, std::forward<Ts>(ts)...);
0035 }
0036
0037 template <class Bool, class... Ts>
0038 constexpr decltype(auto) static_if(Ts&&... ts) noexcept(
0039 noexcept(static_if_impl(Bool{}, std::declval<Ts>()...))) {
0040 return static_if_impl(Bool{}, std::forward<Ts>(ts)...);
0041 }
0042
0043 }
0044 }
0045 }
0046
0047 #endif