Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ BraceWrapping:
AfterControlStatement: false
AfterClass: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
BeforeElse: true
BeforeCatch: true
Expand Down
34 changes: 20 additions & 14 deletions include/sol/base_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ namespace sol {
using sfinae_yes_t = std::true_type;
using sfinae_no_t = std::false_type;

template <typename...>
using void_t = void;
template <auto C>
using constant = std::integral_constant<decltype(C), C>;

template <bool B>
using boolean = std::bool_constant<B>;

using std::void_t;

template <typename T>
using unqualified = std::remove_cv<std::remove_reference_t<T>>;
Expand Down Expand Up @@ -115,39 +120,40 @@ namespace sol {

namespace meta_detail {
template <typename T, template <typename...> class Templ>
struct is_specialization_of : std::false_type { };
template <typename... T, template <typename...> class Templ>
struct is_specialization_of<Templ<T...>, Templ> : std::true_type { };
inline constexpr bool is_specialization_of_v = false;

template <typename... Ts, template <typename...> class Templ>
inline constexpr bool is_specialization_of_v<Templ<Ts...>, Templ> = true;

} // namespace meta_detail

template <typename T, template <typename...> class Templ>
using is_specialization_of = meta_detail::is_specialization_of<std::remove_cv_t<T>, Templ>;
inline constexpr bool is_specialization_of_v = meta_detail::is_specialization_of_v<std::remove_cv_t<T>, Templ>;

template <typename T, template <typename...> class Templ>
inline constexpr bool is_specialization_of_v = is_specialization_of<std::remove_cv_t<T>, Templ>::value;
using is_specialization_of = boolean<is_specialization_of_v<T, Templ>>;

template <typename T>
struct identity {
typedef T type;
using type = T;
};

template <typename T>
using identity_t = typename identity<T>::type;

template <typename T>
using is_builtin_type = std::integral_constant<bool, std::is_arithmetic<T>::value || std::is_pointer<T>::value || std::is_array<T>::value>;
using is_builtin_type = boolean<std::is_arithmetic_v<T> || std::is_pointer_v<T> || std::is_array_v<T>>;

namespace meta_detail {
template <typename T, typename = void>
struct has_internal_marker_impl : std::false_type { };
template <typename T>
struct has_internal_marker_impl<T, void_t<typename T::SOL_INTERNAL_UNSPECIALIZED_MARKER_>> : std::true_type { };
constexpr inline bool has_internal_marker_v = false;

template <typename T>
using has_internal_marker = has_internal_marker_impl<T>;
constexpr inline bool has_internal_marker_v<T, void_t<typename T::SOL_INTERNAL_UNSPECIALIZED_MARKER_>> = true;

template <typename T>
constexpr inline bool has_internal_marker_v = has_internal_marker<T>::value;
using has_internal_marker = boolean<has_internal_marker_v<T>>;

} // namespace meta_detail

} // namespace meta
Expand Down
19 changes: 11 additions & 8 deletions include/sol/bind_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <sol/forward.hpp>
#include <sol/base_traits.hpp>
#include <sol/tuple.hpp>
#include <cstddef>
#include <tuple>

namespace sol { namespace meta {
namespace meta_detail {
Expand All @@ -47,7 +49,7 @@ namespace sol { namespace meta {

template <std::size_t I>
struct void_tuple_element<I, std::tuple<>> {
typedef void type;
using type = void;
};

template <std::size_t I, typename T>
Expand Down Expand Up @@ -510,13 +512,14 @@ namespace sol { namespace meta {
inline static constexpr bool is_member_function = false;
inline static constexpr std::size_t arity = 1;
inline static constexpr std::size_t free_arity = 2;
typedef std::tuple<Arg> args_tuple;
typedef types<Arg> args_list;
typedef types<T, Arg> free_args_list;
typedef meta::tuple_types<return_type> returns_list;
typedef return_type(function_type)(T&, return_type);
typedef return_type (*function_pointer_type)(T&, Arg);
typedef return_type (*free_function_pointer_type)(T&, Arg);
using args_tuple = std::tuple<Arg>;
using args_list = types<Arg>;
using free_args_list = types<T, Arg>;
using returns_list = meta::tuple_types<return_type>;
// This is probably a mistake prolly meant (T& , Arg)
using function_type = return_type(T&, return_type);
using function_pointer_type = return_type (*)(T&, Arg);
using free_function_pointer_type = function_pointer_type;
template <std::size_t i>
using arg_at = void_tuple_element_t<i, args_tuple>;
};
Expand Down
Loading