From 1ac51a02f7671cda3b0a7065e59ca2908a88d8cd Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Sat, 20 May 2017 20:33:18 -0400 Subject: [PATCH] Minor operators.h style cleanups - realign \ at end of macro lines - use 'using A = B;' rather than 'typedef B A;' - use conditional_t --- include/pybind11/operators.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/pybind11/operators.h b/include/pybind11/operators.h index 7d40fb565..d054d9f97 100644 --- a/include/pybind11/operators.h +++ b/include/pybind11/operators.h @@ -49,22 +49,22 @@ template struct op_impl { } /// Operator implementation generator template struct op_ { template void execute(Class &cl, const Extra&... extra) const { - typedef typename Class::type Base; - typedef typename std::conditional::value, Base, L>::type L_type; - typedef typename std::conditional::value, Base, R>::type R_type; - typedef op_impl op; + using Base = typename Class::type; + using L_type = conditional_t::value, Base, L>; + using R_type = conditional_t::value, Base, R>; + using op = op_impl; cl.def(op::name(), &op::execute, is_operator(), extra...); } template void execute_cast(Class &cl, const Extra&... extra) const { - typedef typename Class::type Base; - typedef typename std::conditional::value, Base, L>::type L_type; - typedef typename std::conditional::value, Base, R>::type R_type; - typedef op_impl op; + using Base = typename Class::type; + using L_type = conditional_t::value, Base, L>; + using R_type = conditional_t::value, Base, R>; + using op = op_impl; cl.def(op::name(), &op::execute_cast, is_operator(), extra...); } }; -#define PYBIND11_BINARY_OPERATOR(id, rid, op, expr) \ +#define PYBIND11_BINARY_OPERATOR(id, rid, op, expr) \ template struct op_impl { \ static char const* name() { return "__" #id "__"; } \ static auto execute(const L &l, const R &r) -> decltype(expr) { return (expr); } \ @@ -85,7 +85,7 @@ template op_ op(const T &, const self_t & return op_(); \ } -#define PYBIND11_INPLACE_OPERATOR(id, op, expr) \ +#define PYBIND11_INPLACE_OPERATOR(id, op, expr) \ template struct op_impl { \ static char const* name() { return "__" #id "__"; } \ static auto execute(L &l, const R &r) -> decltype(expr) { return expr; } \ @@ -95,7 +95,7 @@ template op_ op(const self_t &, const T & return op_(); \ } -#define PYBIND11_UNARY_OPERATOR(id, op, expr) \ +#define PYBIND11_UNARY_OPERATOR(id, op, expr) \ template struct op_impl { \ static char const* name() { return "__" #id "__"; } \ static auto execute(const L &l) -> decltype(expr) { return expr; } \