Force constness on ostream operator.

Automatically disable magic for variant types.
This commit is contained in:
ThePhD 2019-12-01 17:40:16 -05:00
parent e26475e75b
commit b0c74207d8
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
5 changed files with 1330 additions and 1324 deletions

View File

@ -39,8 +39,7 @@
#include <iosfwd>
namespace sol {
namespace meta {
namespace sol { namespace meta {
template <typename T>
struct unwrapped {
typedef T type;
@ -191,11 +190,11 @@ namespace sol {
template <template <typename...> class When, std::size_t Limit, std::size_t I, template <typename...> class Pred, typename... Ts>
struct count_when_for_pack : std::integral_constant<std::size_t, 0> {};
template <template <typename...> class When, std::size_t Limit, std::size_t I, template <typename...> class Pred, typename T, typename... Ts>
struct count_when_for_pack<When, Limit, I, Pred, T, Ts...> : conditional_t<
sizeof...(Ts) == 0 || Limit < 2,
std::integral_constant<std::size_t, I + static_cast<std::size_t>(Limit != 0 && Pred<T>::value)>,
count_when_for_pack<When, Limit - static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value), I + static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value && Pred<T>::value), Pred, Ts...>
> {};
struct count_when_for_pack<When, Limit, I, Pred, T, Ts...> : conditional_t < sizeof...(Ts)
== 0
|| Limit<2, std::integral_constant<std::size_t, I + static_cast<std::size_t>(Limit != 0 && Pred<T>::value)>,
count_when_for_pack<When, Limit - static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value),
I + static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value&& Pred<T>::value), Pred, Ts...>> {};
} // namespace meta_detail
template <template <typename...> class Pred, typename... Ts>
@ -283,7 +282,7 @@ namespace sol {
std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
&& std::is_destructible<unqualified_t<T>>::value>> {
struct F {
void operator()() {};
void operator()(){};
};
struct Derived : T, F {};
template <typename U, U>
@ -303,7 +302,7 @@ namespace sol {
std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
&& !std::is_destructible<unqualified_t<T>>::value>> {
struct F {
void operator()() {};
void operator()(){};
};
struct Derived : T, F {
~Derived() = delete;
@ -470,8 +469,8 @@ namespace sol {
template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())>
std::true_type supports_op_less_equal_test(std::reference_wrapper<T>, std::reference_wrapper<U>);
std::false_type supports_op_less_equal_test(...);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<T&>())>
std::true_type supports_ostream_op(std::reference_wrapper<T>, std::reference_wrapper<OS>);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<const T&>())>
std::true_type supports_ostream_op(std::reference_wrapper<const T>, std::reference_wrapper<OS>);
std::false_type supports_ostream_op(...);
template <typename T, typename = decltype(to_string(std::declval<T&>()))>
std::true_type supports_adl_to_string(std::reference_wrapper<T>);
@ -486,7 +485,7 @@ namespace sol {
template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())>
std::true_type supports_op_less_equal_test(const T&, const U&);
std::false_type supports_op_less_equal_test(...);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<T&>())>
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<const T&>())>
std::true_type supports_ostream_op(const T&, const OS&);
std::false_type supports_ostream_op(...);
template <typename T, typename = decltype(to_string(std::declval<T&>()))>
@ -514,7 +513,7 @@ namespace sol {
= decltype(meta_detail::supports_op_less_equal_test(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
template <typename T, typename U = std::ostream>
using supports_ostream_op
= decltype(meta_detail::supports_ostream_op(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
= decltype(meta_detail::supports_ostream_op(std::declval<meta_detail::non_void_t<T>&>(), std::declval<const meta_detail::non_void_t<U>&>()));
template <typename T>
using supports_adl_to_string = decltype(meta_detail::supports_adl_to_string(std::declval<meta_detail::non_void_t<T>&>()));
@ -669,8 +668,7 @@ namespace sol {
constexpr inline bool is_c_str_v = is_c_str<T>::value;
template <typename T>
struct is_move_only
: all<neg<std::is_reference<T>>, neg<std::is_copy_constructible<unqualified_t<T>>>, std::is_move_constructible<unqualified_t<T>>> {};
struct is_move_only : all<neg<std::is_reference<T>>, neg<std::is_copy_constructible<unqualified_t<T>>>, std::is_move_constructible<unqualified_t<T>>> {};
template <typename T>
using is_not_move_only = neg<is_move_only<T>>;
@ -702,7 +700,6 @@ namespace sol {
using type = typename std::iterator_traits<T>::iterator_category;
};
} // namespace meta
} // namespace sol
}} // namespace sol::meta
#endif // SOL_TRAITS_HPP

View File

@ -1308,7 +1308,13 @@ namespace sol {
template <typename T>
struct is_automagical
: std::integral_constant<bool,
std::is_array_v<meta::unqualified_t<T>> || !std::is_same_v<meta::unqualified_t<T>, state> || !std::is_same_v<meta::unqualified_t<T>, state_view>> {
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
!meta::is_specialization_of_v<meta::unqualified_t<T>, std::variant> &&
#endif // std::variant borked in places
#endif // C++17 Features
std::is_array_v<
meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>)> {
};
template <typename T>

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script.
// Generated 2019-11-29 18:08:19.653548 UTC
// This header was generated with sol v3.0.3 (revision 21c0309)
// Generated 2019-12-01 22:39:33.269777 UTC
// This header was generated with sol v3.2.0 (revision e26475e)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script.
// Generated 2019-11-29 18:08:19.142496 UTC
// This header was generated with sol v3.0.3 (revision 21c0309)
// Generated 2019-12-01 22:39:31.432773 UTC
// This header was generated with sol v3.2.0 (revision e26475e)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP
@ -1413,8 +1413,7 @@ namespace sol {
#include <iterator>
#include <iosfwd>
namespace sol {
namespace meta {
namespace sol { namespace meta {
template <typename T>
struct unwrapped {
typedef T type;
@ -1565,11 +1564,11 @@ namespace sol {
template <template <typename...> class When, std::size_t Limit, std::size_t I, template <typename...> class Pred, typename... Ts>
struct count_when_for_pack : std::integral_constant<std::size_t, 0> {};
template <template <typename...> class When, std::size_t Limit, std::size_t I, template <typename...> class Pred, typename T, typename... Ts>
struct count_when_for_pack<When, Limit, I, Pred, T, Ts...> : conditional_t<
sizeof...(Ts) == 0 || Limit < 2,
std::integral_constant<std::size_t, I + static_cast<std::size_t>(Limit != 0 && Pred<T>::value)>,
count_when_for_pack<When, Limit - static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value), I + static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value && Pred<T>::value), Pred, Ts...>
> {};
struct count_when_for_pack<When, Limit, I, Pred, T, Ts...> : conditional_t < sizeof...(Ts)
== 0
|| Limit<2, std::integral_constant<std::size_t, I + static_cast<std::size_t>(Limit != 0 && Pred<T>::value)>,
count_when_for_pack<When, Limit - static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value),
I + static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value&& Pred<T>::value), Pred, Ts...>> {};
} // namespace meta_detail
template <template <typename...> class Pred, typename... Ts>
@ -1657,7 +1656,7 @@ namespace sol {
std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
&& std::is_destructible<unqualified_t<T>>::value>> {
struct F {
void operator()() {};
void operator()(){};
};
struct Derived : T, F {};
template <typename U, U>
@ -1677,7 +1676,7 @@ namespace sol {
std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
&& !std::is_destructible<unqualified_t<T>>::value>> {
struct F {
void operator()() {};
void operator()(){};
};
struct Derived : T, F {
~Derived() = delete;
@ -1844,8 +1843,8 @@ namespace sol {
template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())>
std::true_type supports_op_less_equal_test(std::reference_wrapper<T>, std::reference_wrapper<U>);
std::false_type supports_op_less_equal_test(...);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<T&>())>
std::true_type supports_ostream_op(std::reference_wrapper<T>, std::reference_wrapper<OS>);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<const T&>())>
std::true_type supports_ostream_op(std::reference_wrapper<const T>, std::reference_wrapper<OS>);
std::false_type supports_ostream_op(...);
template <typename T, typename = decltype(to_string(std::declval<T&>()))>
std::true_type supports_adl_to_string(std::reference_wrapper<T>);
@ -1860,7 +1859,7 @@ namespace sol {
template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())>
std::true_type supports_op_less_equal_test(const T&, const U&);
std::false_type supports_op_less_equal_test(...);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<T&>())>
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<const T&>())>
std::true_type supports_ostream_op(const T&, const OS&);
std::false_type supports_ostream_op(...);
template <typename T, typename = decltype(to_string(std::declval<T&>()))>
@ -1888,7 +1887,7 @@ namespace sol {
= decltype(meta_detail::supports_op_less_equal_test(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
template <typename T, typename U = std::ostream>
using supports_ostream_op
= decltype(meta_detail::supports_ostream_op(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
= decltype(meta_detail::supports_ostream_op(std::declval<meta_detail::non_void_t<T>&>(), std::declval<const meta_detail::non_void_t<U>&>()));
template <typename T>
using supports_adl_to_string = decltype(meta_detail::supports_adl_to_string(std::declval<meta_detail::non_void_t<T>&>()));
@ -2043,8 +2042,7 @@ namespace sol {
constexpr inline bool is_c_str_v = is_c_str<T>::value;
template <typename T>
struct is_move_only
: all<neg<std::is_reference<T>>, neg<std::is_copy_constructible<unqualified_t<T>>>, std::is_move_constructible<unqualified_t<T>>> {};
struct is_move_only : all<neg<std::is_reference<T>>, neg<std::is_copy_constructible<unqualified_t<T>>>, std::is_move_constructible<unqualified_t<T>>> {};
template <typename T>
using is_not_move_only = neg<is_move_only<T>>;
@ -2076,8 +2074,7 @@ namespace sol {
using type = typename std::iterator_traits<T>::iterator_category;
};
} // namespace meta
} // namespace sol
}} // namespace sol::meta
// end of sol/traits.hpp
@ -7565,7 +7562,13 @@ namespace sol {
template <typename T>
struct is_automagical
: std::integral_constant<bool,
std::is_array_v<meta::unqualified_t<T>> || !std::is_same_v<meta::unqualified_t<T>, state> || !std::is_same_v<meta::unqualified_t<T>, state_view>> {
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
!meta::is_specialization_of_v<meta::unqualified_t<T>, std::variant> &&
#endif // std::variant borked in places
#endif // C++17 Features
std::is_array_v<
meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>)> {
};
template <typename T>