From 129a7256a95a13f8087d42445e081c196e7c84a3 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Sun, 26 Mar 2017 00:01:52 -0300 Subject: [PATCH] Add and use detail::remove_reference_t Adds `remove_reference_t` and converts various `typename std::remove_reference<...>::type` to using it. --- include/pybind11/cast.h | 4 ++-- include/pybind11/common.h | 2 ++ include/pybind11/eigen.h | 2 +- include/pybind11/pybind11.h | 6 +++--- include/pybind11/pytypes.h | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index c997b90c0..180f48d2a 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -390,7 +390,7 @@ protected: */ template using cast_op_type = - conditional_t::type>::value, + conditional_t>::value, typename std::add_pointer>::type, typename std::add_lvalue_reference>::type>; @@ -883,7 +883,7 @@ public: } static PYBIND11_DESCR name() { return type_descr(_(PYBIND11_STRING_NAME)); } - template using cast_op_type = typename std::remove_reference>::type; + template using cast_op_type = remove_reference_t>; }; template class type_caster> { diff --git a/include/pybind11/common.h b/include/pybind11/common.h index baa84b2c5..8d04c29bc 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -348,10 +348,12 @@ inline internals &get_internals(); using std::enable_if_t; using std::conditional_t; using std::remove_cv_t; +using std::remove_reference_t; #else template using enable_if_t = typename std::enable_if::type; template using conditional_t = typename std::conditional::type; template using remove_cv_t = typename std::remove_cv::type; +template using remove_reference_t = typename std::remove_reference::type; #endif /// Index sequences diff --git a/include/pybind11/eigen.h b/include/pybind11/eigen.h index 8ceb94101..53d4dab08 100644 --- a/include/pybind11/eigen.h +++ b/include/pybind11/eigen.h @@ -542,7 +542,7 @@ public: template struct type_caster::value>> { typedef typename Type::Scalar Scalar; - typedef typename std::remove_reference().outerIndexPtr())>::type StorageIndex; + typedef remove_reference_t().outerIndexPtr())> StorageIndex; typedef typename Type::Index Index; static constexpr bool rowMajor = Type::IsRowMajor; diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 21d911cdf..4954dcf4d 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -56,12 +56,12 @@ public: /// Construct a cpp_function from a lambda function (possibly with internal state) template ::type, + detail::remove_reference_t, std::is_function, std::is_pointer, std::is_member_pointer >::value> > cpp_function(Func &&f, const Extra&... extra) { - using FuncType = typename detail::remove_class::type::operator())>::type; + using FuncType = typename detail::remove_class::operator())>::type; initialize(std::forward(f), (FuncType *) nullptr, extra...); } @@ -93,7 +93,7 @@ protected: template void initialize(Func &&f, Return (*)(Args...), const Extra&... extra) { - struct capture { typename std::remove_reference::type f; }; + struct capture { detail::remove_reference_t f; }; /* Store the function including any extra state it might have (e.g. a lambda capture object) */ auto rec = make_function_record(); diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index 8a8499c13..b186c0b3f 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -44,7 +44,7 @@ using tuple_accessor = accessor; /// Tag and check to identify a class which implements the Python object API class pyobject_tag { }; -template using is_pyobject = std::is_base_of::type>; +template using is_pyobject = std::is_base_of>; /** \rst A mixin class which adds common functions to `handle`, `object` and various accessors.