diff --git a/include/pybind11/attr.h b/include/pybind11/attr.h index 4b4cfc0fd..ba297355d 100644 --- a/include/pybind11/attr.h +++ b/include/pybind11/attr.h @@ -276,7 +276,7 @@ template <> struct process_attribute : process_attribute_default { /// Process a parent class attribute template -struct process_attribute::value>::type> : process_attribute_default { +struct process_attribute::value>> : process_attribute_default { static void init(const handle &h, type_record *r) { r->bases.append(h); } }; @@ -298,13 +298,13 @@ struct process_attribute : process_attribute_default struct process_attribute> : public process_attribute_default> { - template ::type = 0> + template = 0> static void precall(handle args) { keep_alive_impl(Nurse, Patient, args, handle()); } - template ::type = 0> + template = 0> static void postcall(handle, handle) { } - template ::type = 0> + template = 0> static void precall(handle) { } - template ::type = 0> + template = 0> static void postcall(handle args, handle ret) { keep_alive_impl(Nurse, Patient, args, ret); } }; diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 00d19ac3d..780a02efc 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -343,10 +343,10 @@ protected: #else /* Visual Studio 2015's SFINAE implementation doesn't yet handle the above robustly in all situations. Use a workaround that only tests for constructibility for now. */ - template ::value>::type> + template ::value>> static Constructor make_copy_constructor(const T *value) { return [](const void *arg) -> void * { return new T(*((const T *)arg)); }; } - template ::value>::type> + template ::value>> static Constructor make_move_constructor(const T *value) { return [](const void *arg) -> void * { return (void *) new T(std::move(*((T *)arg))); }; } #endif @@ -387,8 +387,8 @@ public: template struct type_caster< - T, typename std::enable_if::value || - std::is_floating_point::value>::type> { + T, enable_if_t::value || + std::is_floating_point::value>> { typedef typename std::conditional::type _py_type_0; typedef typename std::conditional::value, _py_type_0, typename std::make_unsigned<_py_type_0>::type>::type _py_type_1; typedef typename std::conditional::value, double, _py_type_1>::type py_type; @@ -702,20 +702,20 @@ public: return load(src, convert, typename make_index_sequence::type()); } - template ::value && - !std::is_same::value, int>::type = 0> + !std::is_same::value, int> = 0> bool load_args(handle args, handle, bool convert) { return load(args, convert, typename make_index_sequence::type()); } - template ::value, int>::type = 0> + template ::value, int> = 0> bool load_args(handle args, handle, bool convert) { std::get<0>(value).load(args, convert); return true; } - template ::value, int>::type = 0> + template ::value, int> = 0> bool load_args(handle args, handle kwargs, bool convert) { std::get<0>(value).load(args, convert); std::get<1>(value).load(kwargs, convert); @@ -734,11 +734,11 @@ public: return type_descr(_("Tuple[") + element_names() + _("]")); } - template typename std::enable_if::value, ReturnValue>::type call(Func &&f) { + template enable_if_t::value, ReturnValue> call(Func &&f) { return call(std::forward(f), typename make_index_sequence::type()); } - template typename std::enable_if::value, void_type>::type call(Func &&f) { + template enable_if_t::value, void_type> call(Func &&f) { call(std::forward(f), typename make_index_sequence::type()); return void_type(); } @@ -908,12 +908,12 @@ template <> struct handle_type_name { static PYBIND11_DESCR name() { retur template <> struct handle_type_name { static PYBIND11_DESCR name() { return _("**kwargs"); } }; template -struct type_caster::value>::type> { +struct type_caster::value>> { public: - template ::value, int>::type = 0> + template ::value, int> = 0> bool load(handle src, bool /* convert */) { value = type(src); return value.check(); } - template ::value, int>::type = 0> + template ::value, int> = 0> bool load(handle src, bool /* convert */) { value = type(src, true); return value.check(); } static handle cast(const handle &src, return_value_policy /* policy */, handle /* parent */) { @@ -932,21 +932,21 @@ public: // must have ref_count() == 1)h // If any of the above are not satisfied, we fall back to copying. template struct move_is_plain_type : std::false_type {}; -template struct move_is_plain_type struct move_is_plain_type::value && !std::is_pointer::value && !std::is_reference::value && !std::is_const::value - >::type> : std::true_type {}; + >> : std::true_type { }; template struct move_always : std::false_type {}; -template struct move_always struct move_always::value && !std::is_copy_constructible::value && std::is_move_constructible::value && std::is_same>().operator T&()), T&>::value - >::type> : std::true_type {}; + >> : std::true_type { }; template struct move_if_unreferenced : std::false_type {}; -template struct move_if_unreferenced struct move_if_unreferenced::value && !move_always::value && std::is_move_constructible::value && std::is_same>().operator T&()), T&>::value - >::type> : std::true_type {}; + >> : std::true_type { }; template using move_never = std::integral_constant::value && !move_if_unreferenced::value>; // Detect whether returning a `type` from a cast on type's type_caster is going to result in a diff --git a/include/pybind11/common.h b/include/pybind11/common.h index 0c2faf8e9..86af6993a 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -442,14 +442,14 @@ PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used in template struct format_descriptor { }; -template struct format_descriptor::value>::type> { +template struct format_descriptor::value>> { static constexpr const char value[2] = { "bBhHiIqQ"[detail::log2(sizeof(T))*2 + (std::is_unsigned::value ? 1 : 0)], '\0' }; static std::string format() { return value; } }; template constexpr const char format_descriptor< - T, typename std::enable_if::value>::type>::value[2]; + T, detail::enable_if_t::value>>::value[2]; /// RAII wrapper that temporarily clears any Python error state struct error_scope { diff --git a/include/pybind11/descr.h b/include/pybind11/descr.h index ad3c7ddd4..f8a349b1a 100644 --- a/include/pybind11/descr.h +++ b/include/pybind11/descr.h @@ -86,11 +86,11 @@ template struct int_to_str<0, Digits...> { // Ternary description (like std::conditional) template -constexpr typename std::enable_if>::type _(char const(&text1)[Size1], char const(&)[Size2]) { +constexpr enable_if_t> _(char const(&text1)[Size1], char const(&)[Size2]) { return _(text1); } template -constexpr typename std::enable_if>::type _(char const(&)[Size1], char const(&text2)[Size2]) { +constexpr enable_if_t> _(char const(&)[Size1], char const(&text2)[Size2]) { return _(text2); } @@ -164,8 +164,8 @@ PYBIND11_NOINLINE inline descr _(const char *text) { return descr(text, types); } -template PYBIND11_NOINLINE typename std::enable_if::type _(const char *text1, const char *) { return _(text1); } -template PYBIND11_NOINLINE typename std::enable_if::type _(char const *, const char *text2) { return _(text2); } +template PYBIND11_NOINLINE enable_if_t _(const char *text1, const char *) { return _(text1); } +template PYBIND11_NOINLINE enable_if_t _(char const *, const char *text2) { return _(text2); } template PYBIND11_NOINLINE descr _() { const std::type_info *types[2] = { &typeid(Type), nullptr }; diff --git a/include/pybind11/eigen.h b/include/pybind11/eigen.h index 00f05cdf2..c4384ca7a 100644 --- a/include/pybind11/eigen.h +++ b/include/pybind11/eigen.h @@ -46,9 +46,9 @@ public: // type_caster to handle argument copying/forwarding. template class is_eigen_ref { private: - template static typename std::enable_if< + template static enable_if_t< std::is_same::type, Eigen::Ref>::value, - Derived>::type test(const Eigen::Ref &); + Derived> test(const Eigen::Ref &); static void test(...); public: typedef decltype(test(std::declval())) Derived; @@ -77,7 +77,7 @@ public: }; template -struct type_caster::value && !is_eigen_ref::value>::type> { +struct type_caster::value && !is_eigen_ref::value>> { typedef typename Type::Scalar Scalar; static constexpr bool rowMajor = Type::Flags & Eigen::RowMajorBit; static constexpr bool isVector = Type::IsVectorAtCompileTime; @@ -149,18 +149,18 @@ struct type_caster::value && _("[") + rows() + _(", ") + cols() + _("]]")); protected: - template ::type = 0> + template = 0> static PYBIND11_DESCR rows() { return _("m"); } - template ::type = 0> + template = 0> static PYBIND11_DESCR rows() { return _(); } - template ::type = 0> + template = 0> static PYBIND11_DESCR cols() { return _("n"); } - template ::type = 0> + template = 0> static PYBIND11_DESCR cols() { return _(); } }; template -struct type_caster::value && is_eigen_ref::value>::type> { +struct type_caster::value && is_eigen_ref::value>> { protected: using Derived = typename std::remove_const::Derived>::type; using DerivedCaster = type_caster; @@ -181,7 +181,7 @@ public: // type_caster for special matrix types (e.g. DiagonalMatrix): load() is not supported, but we can // cast them into the python domain by first copying to a regular Eigen::Matrix, then casting that. template -struct type_caster::value && !is_eigen_ref::value>::type> { +struct type_caster::value && !is_eigen_ref::value>> { protected: using Matrix = Eigen::Matrix; using MatrixCaster = type_caster; @@ -198,7 +198,7 @@ public: }; template -struct type_caster::value>::type> { +struct type_caster::value>> { typedef typename Type::Scalar Scalar; typedef typename std::remove_reference().outerIndexPtr())>::type StorageIndex; typedef typename Type::Index Index; diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index 0768343fd..81dfaea13 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -486,7 +486,7 @@ public: }; template -struct format_descriptor::value>::type> { +struct format_descriptor::value>> { static std::string format() { return detail::npy_format_descriptor::type>::format(); } @@ -517,7 +517,7 @@ struct is_pod_struct { !std::is_same::type, std::complex>::value }; }; -template struct npy_format_descriptor::value>::type> { +template struct npy_format_descriptor::value>> { private: constexpr static const int values[8] = { npy_api::NPY_BYTE_, npy_api::NPY_UBYTE_, npy_api::NPY_SHORT_, npy_api::NPY_USHORT_, @@ -529,13 +529,13 @@ public: return object(ptr, true); pybind11_fail("Unsupported buffer format!"); } - template ::value, int>::type = 0> + template ::value, int> = 0> static PYBIND11_DESCR name() { return _("int") + _(); } - template ::value, int>::type = 0> + template ::value, int> = 0> static PYBIND11_DESCR name() { return _("uint") + _(); } }; template constexpr const int npy_format_descriptor< - T, typename std::enable_if::value>::type>::values[8]; + T, enable_if_t::value>>::values[8]; #define DECL_FMT(Type, NumPyName, Name) template<> struct npy_format_descriptor { \ enum { value = npy_api::NumPyName }; \ @@ -568,7 +568,7 @@ struct field_descriptor { }; template -struct npy_format_descriptor::value>::type> { +struct npy_format_descriptor::value>> { static PYBIND11_DESCR name() { return _("struct"); } static pybind11::dtype dtype() { @@ -634,9 +634,9 @@ private: }; template -std::string npy_format_descriptor::value>::type>::format_str; +std::string npy_format_descriptor::value>>::format_str; template -PyObject* npy_format_descriptor::value>::type>::dtype_ptr = nullptr; +PyObject* npy_format_descriptor::value>>::dtype_ptr = nullptr; // Extract name, offset and format descriptor for a struct field #define PYBIND11_FIELD_DESCRIPTOR(Type, Field) \ diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 35c5f916d..0f5faa23d 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -867,7 +867,7 @@ public: record.dealloc = dealloc; /* Register base classes specified via template arguments to class_, if any */ - bool unused[] = { (add_base(record), false)... }; + bool unused[] = { (add_base(record), false)..., false }; (void) unused; /* Process optional arguments, if any */ @@ -881,14 +881,14 @@ public: } } - template ::value, int> = 0> + template ::value, int> = 0> static void add_base(detail::type_record &rec) { rec.add_base(&typeid(Base), [](void *src) -> void * { return static_cast(reinterpret_cast(src)); }); } - template ::value, int> = 0> + template ::value, int> = 0> static void add_base(detail::type_record &) { } template @@ -1032,7 +1032,7 @@ private: /// Initialize holder object, variant 2: try to construct from existing holder object, if possible template ::value, int>::type = 0> + detail::enable_if_t::value, int> = 0> static void init_holder_helper(instance_type *inst, const holder_type *holder_ptr, const void * /* dummy */) { if (holder_ptr) new (&inst->holder) holder_type(*holder_ptr); @@ -1042,7 +1042,7 @@ private: /// Initialize holder object, variant 3: holder is not copy constructible (e.g. unique_ptr), always initialize from raw pointer template ::value, int>::type = 0> + detail::enable_if_t::value, int> = 0> static void init_holder_helper(instance_type *inst, const holder_type * /* unused */, const void * /* dummy */) { new (&inst->holder) holder_type(inst->value); } diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index 6313a7ef1..8681bbb12 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -490,7 +490,7 @@ class int_ : public object { public: PYBIND11_OBJECT_DEFAULT(int_, object, PYBIND11_LONG_CHECK) template ::value, int>::type = 0> + detail::enable_if_t::value, int> = 0> int_(T value) { if (sizeof(T) <= sizeof(long)) { if (std::is_signed::value) @@ -507,7 +507,7 @@ public: } template ::value, int>::type = 0> + detail::enable_if_t::value, int> = 0> operator T() const { if (sizeof(T) <= sizeof(long)) { if (std::is_signed::value) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 4390efac9..1f052ee0b 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -112,7 +112,7 @@ template struct list_caster { } template ().reserve(0)), void>::value, int>::type = 0> + enable_if_t().reserve(0)), void>::value, int> = 0> void reserve_maybe(list l, Type *) { value.reserve(l.size()); } void reserve_maybe(list, void *) { } diff --git a/include/pybind11/stl_bind.h b/include/pybind11/stl_bind.h index 92285cec3..24963aaa0 100644 --- a/include/pybind11/stl_bind.h +++ b/include/pybind11/stl_bind.h @@ -40,20 +40,20 @@ struct is_comparable : std::false_type { }; /* For non-map data structures, check whether operator== can be instantiated */ template struct is_comparable< - T, typename std::enable_if::is_element && - container_traits::is_comparable>::type> + T, enable_if_t::is_element && + container_traits::is_comparable>> : std::true_type { }; /* For a vector/map data structure, recursively check the value type (which is std::pair for maps) */ template -struct is_comparable::is_vector>::type> { +struct is_comparable::is_vector>> { static constexpr const bool value = is_comparable::value; }; /* For pairs, recursively check the two data types */ template -struct is_comparable::is_pair>::type> { +struct is_comparable::is_pair>> { static constexpr const bool value = is_comparable::value && is_comparable::value; @@ -64,13 +64,13 @@ template void vector_if_copy_constructibl template void vector_if_equal_operator(const Args&...) { } template void vector_if_insertion_operator(const Args&...) { } -template::value, int>::type = 0> +template::value, int> = 0> void vector_if_copy_constructible(Class_ &cl) { cl.def(pybind11::init(), "Copy constructor"); } -template::value, int>::type = 0> +template::value, int> = 0> void vector_if_equal_operator(Class_ &cl) { using T = typename Vector::value_type; @@ -376,7 +376,7 @@ template void map_if_copy_assi ); } -template::value, int>::type = 0> +template::value, int> = 0> void map_if_copy_assignable(Class_ &cl) { using KeyType = typename Map::key_type; using MappedType = typename Map::mapped_type;