Add and use detail::remove_reference_t

Adds `remove_reference_t` and converts various `typename
std::remove_reference<...>::type` to using it.
This commit is contained in:
Jason Rhinelander 2017-03-26 00:01:52 -03:00
parent 926e2cf333
commit 129a7256a9
5 changed files with 9 additions and 7 deletions

View File

@ -390,7 +390,7 @@ protected:
*/
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 @@ public:
}
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>> {

View File

@ -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 <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

View File

@ -542,7 +542,7 @@ public:
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;

View File

@ -56,12 +56,12 @@ public:
/// 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 @@ protected:
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();

View File

@ -44,7 +44,7 @@ using tuple_accessor = accessor<accessor_policies::tuple_item>;
/// 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.