Add and use detail::remove_reference_t
Adds `remove_reference_t` and converts various `typename
std::remove_reference<...>::type` to using it.
diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h
index c997b90..180f48d 100644
--- a/include/pybind11/cast.h
+++ b/include/pybind11/cast.h
@@ -390,7 +390,7 @@
*/
template <typename T>
using cast_op_type =
- conditional_t<std::is_pointer<typename std::remove_reference<T>::type>::value,
+ conditional_t<std::is_pointer<remove_reference_t<T>>::value,
typename std::add_pointer<intrinsic_t<T>>::type,
typename std::add_lvalue_reference<intrinsic_t<T>>::type>;
@@ -883,7 +883,7 @@
}
static PYBIND11_DESCR name() { return type_descr(_(PYBIND11_STRING_NAME)); }
- template <typename _T> using cast_op_type = typename std::remove_reference<pybind11::detail::cast_op_type<_T>>::type;
+ template <typename _T> using cast_op_type = remove_reference_t<pybind11::detail::cast_op_type<_T>>;
};
template <typename T1, typename T2> class type_caster<std::pair<T1, T2>> {
diff --git a/include/pybind11/common.h b/include/pybind11/common.h
index baa84b2..8d04c29 100644
--- a/include/pybind11/common.h
+++ b/include/pybind11/common.h
@@ -348,10 +348,12 @@
using std::enable_if_t;
using std::conditional_t;
using std::remove_cv_t;
+using std::remove_reference_t;
#else
template <bool B, typename T = void> using enable_if_t = typename std::enable_if<B, T>::type;
template <bool B, typename T, typename F> using conditional_t = typename std::conditional<B, T, F>::type;
template <typename T> using remove_cv_t = typename std::remove_cv<T>::type;
+template <typename T> using remove_reference_t = typename std::remove_reference<T>::type;
#endif
/// Index sequences
diff --git a/include/pybind11/eigen.h b/include/pybind11/eigen.h
index 8ceb941..53d4dab 100644
--- a/include/pybind11/eigen.h
+++ b/include/pybind11/eigen.h
@@ -542,7 +542,7 @@
template<typename Type>
struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
typedef typename Type::Scalar Scalar;
- typedef typename std::remove_reference<decltype(*std::declval<Type>().outerIndexPtr())>::type StorageIndex;
+ typedef remove_reference_t<decltype(*std::declval<Type>().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 21d911c..4954dcf 100644
--- a/include/pybind11/pybind11.h
+++ b/include/pybind11/pybind11.h
@@ -56,12 +56,12 @@
/// Construct a cpp_function from a lambda function (possibly with internal state)
template <typename Func, typename... Extra, typename = detail::enable_if_t<
detail::satisfies_none_of<
- typename std::remove_reference<Func>::type,
+ detail::remove_reference_t<Func>,
std::is_function, std::is_pointer, std::is_member_pointer
>::value>
>
cpp_function(Func &&f, const Extra&... extra) {
- using FuncType = typename detail::remove_class<decltype(&std::remove_reference<Func>::type::operator())>::type;
+ using FuncType = typename detail::remove_class<decltype(&detail::remove_reference_t<Func>::operator())>::type;
initialize(std::forward<Func>(f),
(FuncType *) nullptr, extra...);
}
@@ -93,7 +93,7 @@
template <typename Func, typename Return, typename... Args, typename... Extra>
void initialize(Func &&f, Return (*)(Args...), const Extra&... extra) {
- struct capture { typename std::remove_reference<Func>::type f; };
+ struct capture { detail::remove_reference_t<Func> 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 8a8499c..b186c0b 100644
--- a/include/pybind11/pytypes.h
+++ b/include/pybind11/pytypes.h
@@ -44,7 +44,7 @@
/// Tag and check to identify a class which implements the Python object API
class pyobject_tag { };
-template <typename T> using is_pyobject = std::is_base_of<pyobject_tag, typename std::remove_reference<T>::type>;
+template <typename T> using is_pyobject = std::is_base_of<pyobject_tag, remove_reference_t<T>>;
/** \rst
A mixin class which adds common functions to `handle`, `object` and various accessors.