From b0c74207d8d86b6d6b6137252bb6494f33947a25 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sun, 1 Dec 2019 17:40:16 -0500 Subject: [PATCH] Force constness on ostream operator. Automatically disable magic for variant types. --- include/sol/traits.hpp | 1307 ++++++++++++++++--------------- include/sol/types.hpp | 8 +- include/sol/usertype_core.hpp | 8 +- single/include/sol/forward.hpp | 4 +- single/include/sol/sol.hpp | 1327 ++++++++++++++++---------------- 5 files changed, 1330 insertions(+), 1324 deletions(-) diff --git a/include/sol/traits.hpp b/include/sol/traits.hpp index b47fdc94..ca2b8ff2 100644 --- a/include/sol/traits.hpp +++ b/include/sol/traits.hpp @@ -39,670 +39,667 @@ #include -namespace sol { - namespace meta { - template - struct unwrapped { - typedef T type; +namespace sol { namespace meta { + template + struct unwrapped { + typedef T type; + }; + + template + struct unwrapped> { + typedef T type; + }; + + template + using unwrapped_t = typename unwrapped::type; + + template + struct unwrap_unqualified : unwrapped> {}; + + template + using unwrap_unqualified_t = typename unwrap_unqualified::type; + + template + struct remove_member_pointer; + + template + struct remove_member_pointer { + typedef R type; + }; + + template + struct remove_member_pointer { + typedef R type; + }; + + template + using remove_member_pointer_t = remove_member_pointer; + + template + struct all_same : std::true_type {}; + + template + struct all_same : std::integral_constant::value && all_same::value> {}; + + template + struct any_same : std::false_type {}; + + template + struct any_same : std::integral_constant::value || any_same::value> {}; + + template + constexpr inline bool any_same_v = any_same::value; + + template + using boolean = std::integral_constant; + + template + constexpr inline bool boolean_v = boolean::value; + + template + using neg = boolean; + + template + constexpr inline bool neg_v = neg::value; + + template + struct all : boolean {}; + + template + struct all : std::conditional_t, boolean> {}; + + template + struct any : boolean {}; + + template + struct any : std::conditional_t, any> {}; + + template + constexpr inline bool all_v = all::value; + + template + constexpr inline bool any_v = any::value; + + enum class enable_t { _ }; + + constexpr const auto enabler = enable_t::_; + + template + using disable_if_t = std::enable_if_t; + + template + using enable = std::enable_if_t::value, enable_t>; + + template + using disable = std::enable_if_t>::value, enable_t>; + + template + using enable_any = std::enable_if_t::value, enable_t>; + + template + using disable_any = std::enable_if_t>::value, enable_t>; + + template + struct find_in_pack_v : boolean {}; + + template + struct find_in_pack_v : any, find_in_pack_v> {}; + + namespace meta_detail { + template + struct index_in_pack : std::integral_constant {}; + + template + struct index_in_pack + : conditional_t::value, std::integral_constant, index_in_pack> {}; + } // namespace meta_detail + + template + struct index_in_pack : meta_detail::index_in_pack<0, T, Args...> {}; + + template + struct index_in : meta_detail::index_in_pack<0, T, List> {}; + + template + struct index_in> : meta_detail::index_in_pack<0, T, Args...> {}; + + template + struct at_in_pack {}; + + template + using at_in_pack_t = typename at_in_pack::type; + + template + struct at_in_pack : std::conditional> {}; + + template + struct at_in_pack<0, Arg, Args...> { + typedef Arg type; + }; + + namespace meta_detail { + template + using on_even = meta::boolean<(TI::value % 2) == 0>; + + template + using on_odd = meta::boolean<(TI::value % 2) == 1>; + + template + using on_always = std::true_type; + + template