diff --git a/include/triton/Analysis/Allocation.h b/include/triton/Analysis/Allocation.h index c0f54232a..c7353b3a5 100644 --- a/include/triton/Analysis/Allocation.h +++ b/include/triton/Analysis/Allocation.h @@ -156,7 +156,7 @@ private: private: template - void addBuffer(KeyType &key, Args &&... args) { + void addBuffer(KeyType &key, Args &&...args) { auto buffer = BufferT(Kind, std::forward(args)...); bufferSet[buffer.id] = std::move(buffer); if constexpr (Kind == BufferT::BufferKind::Explicit) { diff --git a/include/triton/tools/thread_pool.h b/include/triton/tools/thread_pool.h index e8a6ca6ca..045e983f8 100644 --- a/include/triton/tools/thread_pool.h +++ b/include/triton/tools/thread_pool.h @@ -35,7 +35,7 @@ public: } template - auto enqueue(F &&f, Args &&... args) + auto enqueue(F &&f, Args &&...args) -> std::future::type> { using return_type = typename std::result_of::type; diff --git a/python/src/pybind11/attr.h b/python/src/pybind11/attr.h index eada4e1f1..3d4c54091 100644 --- a/python/src/pybind11/attr.h +++ b/python/src/pybind11/attr.h @@ -554,13 +554,13 @@ struct process_attribute> /// Recursively iterate over variadic template arguments template struct process_attributes { - static void init(const Args &... args, function_record *r) { + static void init(const Args &...args, function_record *r) { int unused[] = { 0, (process_attribute::type>::init(args, r), 0)...}; ignore_unused(unused); } - static void init(const Args &... args, type_record *r) { + static void init(const Args &...args, type_record *r) { int unused[] = { 0, (process_attribute::type>::init(args, r), 0)...}; diff --git a/python/src/pybind11/cast.h b/python/src/pybind11/cast.h index 49a9adb29..5e7c6648e 100644 --- a/python/src/pybind11/cast.h +++ b/python/src/pybind11/cast.h @@ -1231,7 +1231,7 @@ public: } template using cast_op_type = void *&; - operator void * &() { return value; } + operator void *&() { return value; } static constexpr auto name = _("capsule"); private: @@ -1336,9 +1336,12 @@ template struct string_caster { #endif } - object utfNbytes = reinterpret_steal(PyUnicode_AsEncodedString( - load_src.ptr(), - UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr)); + object utfNbytes = reinterpret_steal( + PyUnicode_AsEncodedString(load_src.ptr(), + UTF_N == 8 ? "utf-8" + : UTF_N == 16 ? "utf-16" + : "utf-32", + nullptr)); if (!utfNbytes) { PyErr_Clear(); return false; @@ -1377,20 +1380,21 @@ template struct string_caster { private: static handle decode_utfN(const char *buffer, ssize_t nbytes) { #if !defined(PYPY_VERSION) - return UTF_N == 8 - ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr) - : UTF_N == 16 - ? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr) - : PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr); + return UTF_N == 8 ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr) + : UTF_N == 16 + ? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr) + : PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr); #else // PyPy seems to have multiple problems related to PyUnicode_UTF*: the UTF8 // version sometimes segfaults for unknown reasons, while the UTF16 and 32 // versions require a non-const char * arguments, which is also a nuisance, // so bypass the whole thing by just passing the encoding as a string value, // which works properly: - return PyUnicode_Decode( - buffer, nbytes, - UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr); + return PyUnicode_Decode(buffer, nbytes, + UTF_N == 8 ? "utf-8" + : UTF_N == 16 ? "utf-16" + : "utf-32", + nullptr); #endif } @@ -1495,11 +1499,12 @@ public: if (StringCaster::UTF_N == 8 && str_len > 1 && str_len <= 4) { unsigned char v0 = static_cast(value[0]); size_t char0_bytes = - !(v0 & 0x80) ? 1 : // low bits only: 0-127 - (v0 & 0xE0) == 0xC0 ? 2 : // 0b110xxxxx - start of 2-byte sequence - (v0 & 0xF0) == 0xE0 ? 3 - : // 0b1110xxxx - start of 3-byte sequence - 4; // 0b11110xxx - start of 4-byte sequence + !(v0 & 0x80) ? 1 : // low bits only: 0-127 + (v0 & 0xE0) == 0xC0 ? 2 + : // 0b110xxxxx - start of 2-byte sequence + (v0 & 0xF0) == 0xE0 ? 3 + : // 0b1110xxxx - start of 3-byte sequence + 4; // 0b11110xxx - start of 4-byte sequence if (char0_bytes == str_len) { // If we have a 128-255 value, we can decode it into a single char: @@ -2040,7 +2045,7 @@ tuple make_tuple() { template -tuple make_tuple(Args &&... args_) { +tuple make_tuple(Args &&...args_) { constexpr size_t size = sizeof...(Args); std::array args{ {reinterpret_steal(detail::make_caster::cast( @@ -2261,7 +2266,7 @@ private: template class simple_collector { public: template - explicit simple_collector(Ts &&... values) + explicit simple_collector(Ts &&...values) : m_args(pybind11::make_tuple(std::forward(values)...)) {} const tuple &args() const & { return m_args; } @@ -2285,7 +2290,7 @@ private: /// Python function call template class unpacking_collector { public: - template explicit unpacking_collector(Ts &&... values) { + template explicit unpacking_collector(Ts &&...values) { // Tuples aren't (easily) resizable so a list is needed for collection, // but the actual function call strictly requires a tuple. auto args_list = list(); @@ -2407,7 +2412,7 @@ private: /// Collect only positional arguments for a Python function call template ...>::value>> -simple_collector collect_arguments(Args &&... args) { +simple_collector collect_arguments(Args &&...args) { return simple_collector(std::forward(args)...); } @@ -2415,7 +2420,7 @@ simple_collector collect_arguments(Args &&... args) { /// when needed) template ...>::value>> -unpacking_collector collect_arguments(Args &&... args) { +unpacking_collector collect_arguments(Args &&...args) { // Following argument order rules for generalized unpacking according to PEP // 448 static_assert(constexpr_last() < @@ -2430,14 +2435,14 @@ unpacking_collector collect_arguments(Args &&... args) { template template -object object_api::operator()(Args &&... args) const { +object object_api::operator()(Args &&...args) const { return detail::collect_arguments(std::forward(args)...) .call(derived().ptr()); } template template -object object_api::call(Args &&... args) const { +object object_api::call(Args &&...args) const { return operator()(std::forward(args)...); } diff --git a/python/src/pybind11/detail/common.h b/python/src/pybind11/detail/common.h index c874a1779..b0d0b148f 100644 --- a/python/src/pybind11/detail/common.h +++ b/python/src/pybind11/detail/common.h @@ -808,9 +808,9 @@ struct is_fmt_numeric::value>> { ? 0 : 1 + (std::is_integral::value ? detail::log2(sizeof(T)) * 2 + std::is_unsigned::value - : 8 + (std::is_same::value - ? 1 - : std::is_same::value ? 2 : 0)); + : 8 + (std::is_same::value ? 1 + : std::is_same::value ? 2 + : 0)); }; NAMESPACE_END(detail) diff --git a/python/src/pybind11/detail/descr.h b/python/src/pybind11/detail/descr.h index 38f8b7433..f44d91f7d 100644 --- a/python/src/pybind11/detail/descr.h +++ b/python/src/pybind11/detail/descr.h @@ -104,7 +104,7 @@ constexpr descr concat(const descr &descr) { } template -constexpr auto concat(const descr &d, const Args &... args) +constexpr auto concat(const descr &d, const Args &...args) -> decltype(std::declval>() + concat(args...)) { return d + _(", ") + concat(args...); } diff --git a/python/src/pybind11/detail/init.h b/python/src/pybind11/detail/init.h index a48dfd419..ac9bc5041 100644 --- a/python/src/pybind11/detail/init.h +++ b/python/src/pybind11/detail/init.h @@ -66,13 +66,13 @@ template constexpr bool is_alias(void *) { return false; } template < typename Class, typename... Args, detail::enable_if_t::value, int> = 0> -inline Class *construct_or_initialize(Args &&... args) { +inline Class *construct_or_initialize(Args &&...args) { return new Class(std::forward(args)...); } template < typename Class, typename... Args, detail::enable_if_t::value, int> = 0> -inline Class *construct_or_initialize(Args &&... args) { +inline Class *construct_or_initialize(Args &&...args) { return new Class{std::forward(args)...}; } @@ -200,7 +200,7 @@ void construct(value_and_holder &v_h, Alias &&result, bool) { template struct constructor { template = 0> - static void execute(Class &cl, const Extra &... extra) { + static void execute(Class &cl, const Extra &...extra) { cl.def( "__init__", [](value_and_holder &v_h, Args... args) { @@ -214,7 +214,7 @@ template struct constructor { enable_if_t, Args...>::value, int> = 0> - static void execute(Class &cl, const Extra &... extra) { + static void execute(Class &cl, const Extra &...extra) { cl.def( "__init__", [](value_and_holder &v_h, Args... args) { @@ -232,7 +232,7 @@ template struct constructor { enable_if_t, Args...>::value, int> = 0> - static void execute(Class &cl, const Extra &... extra) { + static void execute(Class &cl, const Extra &...extra) { cl.def( "__init__", [](value_and_holder &v_h, Args... args) { @@ -249,7 +249,7 @@ template struct alias_constructor { enable_if_t, Args...>::value, int> = 0> - static void execute(Class &cl, const Extra &... extra) { + static void execute(Class &cl, const Extra &...extra) { cl.def( "__init__", [](value_and_holder &v_h, Args... args) { @@ -280,7 +280,7 @@ struct factory { // either already be an alias instance, or the alias needs to be constructible // from a `Class &&` argument. template - void execute(Class &cl, const Extra &... extra) && { + void execute(Class &cl, const Extra &...extra) && { #if defined(PYBIND11_CPP14) cl.def( "__init__", @@ -323,7 +323,7 @@ struct factory { // the direct class (i.e. not inherited), the alias factory when `self` is a // Python-side subtype. template - void execute(Class &cl, const Extra &... extra) && { + void execute(Class &cl, const Extra &...extra) && { static_assert(Class::has_alias, "The two-argument version of `py::init()` can " "only be used if the class has an alias"); @@ -389,7 +389,7 @@ struct pickle_factory { : get(std::forward(get)), set(std::forward(set)) {} template - void execute(Class &cl, const Extra &... extra) && { + void execute(Class &cl, const Extra &...extra) && { cl.def("__getstate__", std::move(get)); #if defined(PYBIND11_CPP14) diff --git a/python/src/pybind11/detail/internals.h b/python/src/pybind11/detail/internals.h index 25a068aec..d3bedee82 100644 --- a/python/src/pybind11/detail/internals.h +++ b/python/src/pybind11/detail/internals.h @@ -297,7 +297,7 @@ inline type_map ®istered_local_types_cpp() { /// duration -- the internal strings are only cleared when the program exits or /// after interpreter shutdown (when embedding), and so are suitable for c-style /// strings needed by Python internals (such as PyTypeObject's tp_name). -template const char *c_str(Args &&... args) { +template const char *c_str(Args &&...args) { auto &strings = get_internals().static_strings; strings.emplace_front(std::forward(args)...); return strings.front().c_str(); diff --git a/python/src/pybind11/eigen.h b/python/src/pybind11/eigen.h index 4416f91b1..5d94ab3f6 100644 --- a/python/src/pybind11/eigen.h +++ b/python/src/pybind11/eigen.h @@ -164,7 +164,9 @@ template struct EigenProps { static constexpr EigenIndex inner_stride = if_zero::value, outer_stride = if_zero < StrideType::OuterStrideAtCompileTime, - vector ? size : row_major ? cols : rows > ::value; + vector ? size + : row_major ? cols + : rows > ::value; static constexpr bool dynamic_stride = inner_stride == Eigen::Dynamic && outer_stride == Eigen::Dynamic; static constexpr bool requires_row_major = @@ -471,15 +473,14 @@ private: using props = EigenProps; using Scalar = typename props::Scalar; using MapType = Eigen::Map; - using Array = - array_t; + using Array = array_t< + Scalar, + array::forcecast | + ((props::row_major ? props::inner_stride : props::outer_stride) == 1 + ? array::c_style + : (props::row_major ? props::outer_stride : props::inner_stride) == 1 + ? array::f_style + : 0)>; static constexpr bool need_writeable = is_eigen_mutable_map::value; // Delay construction (these have no default constructor) std::unique_ptr map; diff --git a/python/src/pybind11/numpy.h b/python/src/pybind11/numpy.h index 1993d5479..fe13f1f60 100644 --- a/python/src/pybind11/numpy.h +++ b/python/src/pybind11/numpy.h @@ -1299,10 +1299,10 @@ private: #define PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, Name) \ ::pybind11::detail::field_descriptor { \ Name, offsetof(T, Field), sizeof(decltype(std::declval().Field)), \ - ::pybind11::format_descriptor().Field)>::format(), \ - ::pybind11::detail::npy_format_descriptor().Field)>::dtype() \ + ::pybind11::format_descriptor< \ + decltype(std::declval().Field)>::format(), \ + ::pybind11::detail::npy_format_descriptor< \ + decltype(std::declval().Field)>::dtype() \ } // Extract name, offset and format descriptor for a struct field @@ -1576,10 +1576,9 @@ broadcast_trivial broadcast(const std::array &buffers, } } - return trivial_broadcast_c - ? broadcast_trivial::c_trivial - : trivial_broadcast_f ? broadcast_trivial::f_trivial - : broadcast_trivial::non_trivial; + return trivial_broadcast_c ? broadcast_trivial::c_trivial + : trivial_broadcast_f ? broadcast_trivial::f_trivial + : broadcast_trivial::non_trivial; } template struct vectorize_arg { @@ -1643,7 +1642,7 @@ private: // we can store vectorized buffer_infos in an array (argument VIndex has // its buffer at index BIndex in the array). template - object run(typename vectorize_arg::type &... args, + object run(typename vectorize_arg::type &...args, index_sequence i_seq, index_sequence vi_seq, index_sequence bi_seq) { diff --git a/python/src/pybind11/operators.h b/python/src/pybind11/operators.h index 1022048c3..06c557ad2 100644 --- a/python/src/pybind11/operators.h +++ b/python/src/pybind11/operators.h @@ -93,7 +93,7 @@ template struct op_impl {}; /// Operator implementation generator template struct op_ { template - void execute(Class &cl, const Extra &... extra) const { + void execute(Class &cl, const Extra &...extra) const { using Base = typename Class::type; using L_type = conditional_t::value, Base, L>; using R_type = conditional_t::value, Base, R>; @@ -102,12 +102,13 @@ template struct op_ { #if PY_MAJOR_VERSION < 3 if (id == op_truediv || id == op_itruediv) cl.def(id == op_itruediv ? "__idiv__" - : ot == op_l ? "__div__" : "__rdiv__", + : ot == op_l ? "__div__" + : "__rdiv__", &op::execute, is_operator(), extra...); #endif } template - void execute_cast(Class &cl, const Extra &... extra) const { + void execute_cast(Class &cl, const Extra &...extra) const { using Base = typename Class::type; using L_type = conditional_t::value, Base, L>; using R_type = conditional_t::value, Base, R>; @@ -116,7 +117,8 @@ template struct op_ { #if PY_MAJOR_VERSION < 3 if (id == op_truediv || id == op_itruediv) cl.def(id == op_itruediv ? "__idiv__" - : ot == op_l ? "__div__" : "__rdiv__", + : ot == op_l ? "__div__" + : "__rdiv__", &op::execute, is_operator(), extra...); #endif } @@ -177,19 +179,19 @@ template struct op_ { PYBIND11_BINARY_OPERATOR(sub, rsub, operator-, l - r) PYBIND11_BINARY_OPERATOR(add, radd, operator+, l + r) -PYBIND11_BINARY_OPERATOR(mul, rmul, operator*, l * r) +PYBIND11_BINARY_OPERATOR(mul, rmul, operator*, l *r) PYBIND11_BINARY_OPERATOR(truediv, rtruediv, operator/, l / r) PYBIND11_BINARY_OPERATOR(mod, rmod, operator%, l % r) PYBIND11_BINARY_OPERATOR(lshift, rlshift, operator<<, l << r) -PYBIND11_BINARY_OPERATOR(rshift, rrshift, operator>>, l>> r) -PYBIND11_BINARY_OPERATOR(and, rand, operator&, l & r) +PYBIND11_BINARY_OPERATOR(rshift, rrshift, operator>>, l >> r) +PYBIND11_BINARY_OPERATOR(and, rand, operator&, l &r) PYBIND11_BINARY_OPERATOR(xor, rxor, operator^, l ^ r) PYBIND11_BINARY_OPERATOR(eq, eq, operator==, l == r) PYBIND11_BINARY_OPERATOR(ne, ne, operator!=, l != r) PYBIND11_BINARY_OPERATOR(or, ror, operator|, l | r) -PYBIND11_BINARY_OPERATOR(gt, lt, operator>, l> r) +PYBIND11_BINARY_OPERATOR(gt, lt, operator>, l > r) PYBIND11_BINARY_OPERATOR(ge, le, operator>=, l >= r) -PYBIND11_BINARY_OPERATOR(lt, gt, operator<, l>=, l >>= r) PYBIND11_INPLACE_OPERATOR(iand, operator&=, l &= r) PYBIND11_INPLACE_OPERATOR(ixor, operator^=, l ^= r) PYBIND11_INPLACE_OPERATOR(ior, operator|=, l |= r) -PYBIND11_UNARY_OPERATOR(neg, operator-, - l) -PYBIND11_UNARY_OPERATOR(pos, operator+, + l) +PYBIND11_UNARY_OPERATOR(neg, operator-, -l) +PYBIND11_UNARY_OPERATOR(pos, operator+, +l) PYBIND11_UNARY_OPERATOR(abs, abs, std::abs(l)) PYBIND11_UNARY_OPERATOR(hash, hash, std::hash()(l)) -PYBIND11_UNARY_OPERATOR(invert, operator~,(~l)) +PYBIND11_UNARY_OPERATOR(invert, operator~, (~l)) PYBIND11_UNARY_OPERATOR(bool, operator!, !!l) PYBIND11_UNARY_OPERATOR(int, int_, (int)l) PYBIND11_UNARY_OPERATOR(float, float_, (double)l) diff --git a/python/src/pybind11/pybind11.h b/python/src/pybind11/pybind11.h index c1c8c8870..f846e68c5 100644 --- a/python/src/pybind11/pybind11.h +++ b/python/src/pybind11/pybind11.h @@ -74,7 +74,7 @@ public: /// Construct a cpp_function from a vanilla function pointer template - cpp_function(Return (*f)(Args...), const Extra &... extra) { + cpp_function(Return (*f)(Args...), const Extra &...extra) { initialize(f, f, extra...); } @@ -82,14 +82,14 @@ public: /// state) template ::value>> - cpp_function(Func &&f, const Extra &... extra) { + cpp_function(Func &&f, const Extra &...extra) { initialize(std::forward(f), (detail::function_signature_t *)nullptr, extra...); } /// Construct a cpp_function from a class method (non-const) template - cpp_function(Return (Class::*f)(Arg...), const Extra &... extra) { + cpp_function(Return (Class::*f)(Arg...), const Extra &...extra) { initialize( [f](Class *c, Arg... args) -> Return { return (c->*f)(args...); }, (Return(*)(Class *, Arg...)) nullptr, extra...); @@ -97,7 +97,7 @@ public: /// Construct a cpp_function from a class method (const) template - cpp_function(Return (Class::*f)(Arg...) const, const Extra &... extra) { + cpp_function(Return (Class::*f)(Arg...) const, const Extra &...extra) { initialize( [f](const Class *c, Arg... args) -> Return { return (c->*f)(args...); }, (Return(*)(const Class *, Arg...)) nullptr, extra...); @@ -114,7 +114,7 @@ protected: /// Special internal constructor for functors, lambda functions, etc. template - void initialize(Func &&f, Return (*)(Args...), const Extra &... extra) { + void initialize(Func &&f, Return (*)(Args...), const Extra &...extra) { using namespace detail; struct capture { remove_reference_t f; @@ -924,7 +924,7 @@ public: details on the ``Extra&& ... extra`` argument, see section :ref:`extras`. \endrst */ template - module &def(const char *name_, Func &&f, const Extra &... extra) { + module &def(const char *name_, Func &&f, const Extra &...extra) { cpp_function func(std::forward(f), name(name_), scope(*this), sibling(getattr(*this, name_, none())), extra...); // NB: allow overwriting here because cpp_function sets up a chain with the @@ -1104,8 +1104,8 @@ protected: /// Set the pointer to operator new if it exists. The cast is needed because it /// can be overloaded. -template (T::operator new))>> +template ( + T::operator new))>> void set_operator_new(type_record *r) { r->operator_new = &T::operator new; } @@ -1204,7 +1204,7 @@ public: PYBIND11_OBJECT(class_, generic_type, PyType_Check) template - class_(handle scope, const char *name, const Extra &... extra) { + class_(handle scope, const char *name, const Extra &...extra) { using namespace detail; // MI can only be specified via class_ template options, not constructor @@ -1263,7 +1263,7 @@ public: static void add_base(detail::type_record &) {} template - class_ &def(const char *name_, Func &&f, const Extra &... extra) { + class_ &def(const char *name_, Func &&f, const Extra &...extra) { cpp_function cf(method_adaptor(std::forward(f)), name(name_), is_method(*this), sibling(getattr(*this, name_, none())), extra...); @@ -1272,7 +1272,7 @@ public: } template - class_ &def_static(const char *name_, Func &&f, const Extra &... extra) { + class_ &def_static(const char *name_, Func &&f, const Extra &...extra) { static_assert( !std::is_member_function_pointer::value, "def_static(...) called with a non-static member function pointer"); @@ -1284,43 +1284,42 @@ public: template - class_ &def(const detail::op_ &op, const Extra &... extra) { + class_ &def(const detail::op_ &op, const Extra &...extra) { op.execute(*this, extra...); return *this; } template - class_ &def_cast(const detail::op_ &op, - const Extra &... extra) { + class_ &def_cast(const detail::op_ &op, const Extra &...extra) { op.execute_cast(*this, extra...); return *this; } template class_ &def(const detail::initimpl::constructor &init, - const Extra &... extra) { + const Extra &...extra) { init.execute(*this, extra...); return *this; } template class_ &def(const detail::initimpl::alias_constructor &init, - const Extra &... extra) { + const Extra &...extra) { init.execute(*this, extra...); return *this; } template class_ &def(detail::initimpl::factory &&init, - const Extra &... extra) { + const Extra &...extra) { std::move(init).execute(*this, extra...); return *this; } template class_ &def(detail::initimpl::pickle_factory &&pf, - const Extra &... extra) { + const Extra &...extra) { std::move(pf).execute(*this, extra...); return *this; } @@ -1352,7 +1351,7 @@ public: } template - class_ &def_readwrite(const char *name, D C::*pm, const Extra &... extra) { + class_ &def_readwrite(const char *name, D C::*pm, const Extra &...extra) { static_assert( std::is_same::value || std::is_base_of::value, "def_readwrite() requires a class member (or base class member)"); @@ -1367,7 +1366,7 @@ public: template class_ &def_readonly(const char *name, const D C::*pm, - const Extra &... extra) { + const Extra &...extra) { static_assert( std::is_same::value || std::is_base_of::value, "def_readonly() requires a class member (or base class member)"); @@ -1379,8 +1378,7 @@ public: } template - class_ &def_readwrite_static(const char *name, D *pm, - const Extra &... extra) { + class_ &def_readwrite_static(const char *name, D *pm, const Extra &...extra) { cpp_function fget([pm](object) -> const D & { return *pm; }, scope(*this)), fset([pm](object, const D &value) { *pm = value; }, scope(*this)); def_property_static(name, fget, fset, return_value_policy::reference, @@ -1390,7 +1388,7 @@ public: template class_ &def_readonly_static(const char *name, const D *pm, - const Extra &... extra) { + const Extra &...extra) { cpp_function fget([pm](object) -> const D & { return *pm; }, scope(*this)); def_property_readonly_static(name, fget, return_value_policy::reference, extra...); @@ -1400,7 +1398,7 @@ public: /// Uses return_value_policy::reference_internal by default template class_ &def_property_readonly(const char *name, const Getter &fget, - const Extra &... extra) { + const Extra &...extra) { return def_property_readonly(name, cpp_function(method_adaptor(fget)), return_value_policy::reference_internal, extra...); @@ -1409,14 +1407,14 @@ public: /// Uses cpp_function's return_value_policy by default template class_ &def_property_readonly(const char *name, const cpp_function &fget, - const Extra &... extra) { + const Extra &...extra) { return def_property(name, fget, nullptr, extra...); } /// Uses return_value_policy::reference by default template class_ &def_property_readonly_static(const char *name, const Getter &fget, - const Extra &... extra) { + const Extra &...extra) { return def_property_readonly_static( name, cpp_function(fget), return_value_policy::reference, extra...); } @@ -1425,20 +1423,20 @@ public: template class_ &def_property_readonly_static(const char *name, const cpp_function &fget, - const Extra &... extra) { + const Extra &...extra) { return def_property_static(name, fget, nullptr, extra...); } /// Uses return_value_policy::reference_internal by default template class_ &def_property(const char *name, const Getter &fget, const Setter &fset, - const Extra &... extra) { + const Extra &...extra) { return def_property(name, fget, cpp_function(method_adaptor(fset)), extra...); } template class_ &def_property(const char *name, const Getter &fget, - const cpp_function &fset, const Extra &... extra) { + const cpp_function &fset, const Extra &...extra) { return def_property(name, cpp_function(method_adaptor(fget)), fset, return_value_policy::reference_internal, extra...); } @@ -1446,15 +1444,14 @@ public: /// Uses cpp_function's return_value_policy by default template class_ &def_property(const char *name, const cpp_function &fget, - const cpp_function &fset, const Extra &... extra) { + const cpp_function &fset, const Extra &...extra) { return def_property_static(name, fget, fset, is_method(*this), extra...); } /// Uses return_value_policy::reference by default template class_ &def_property_static(const char *name, const Getter &fget, - const cpp_function &fset, - const Extra &... extra) { + const cpp_function &fset, const Extra &...extra) { return def_property_static(name, cpp_function(fget), fset, return_value_policy::reference, extra...); } @@ -1462,8 +1459,7 @@ public: /// Uses cpp_function's return_value_policy by default template class_ &def_property_static(const char *name, const cpp_function &fget, - const cpp_function &fset, - const Extra &... extra) { + const cpp_function &fset, const Extra &...extra) { static_assert( 0 == detail::constexpr_sum(std::is_base_of::value...), "Argument annotations are not allowed for properties"); @@ -1782,7 +1778,7 @@ public: using Scalar = typename std::underlying_type::type; template - enum_(const handle &scope, const char *name, const Extra &... extra) + enum_(const handle &scope, const char *name, const Extra &...extra) : class_(scope, name, extra...), m_base(*this, scope) { constexpr bool is_arithmetic = detail::any_of...>::value; @@ -1898,7 +1894,7 @@ template ()), typename... Extra> -iterator make_iterator(Iterator first, Sentinel last, Extra &&... extra) { +iterator make_iterator(Iterator first, Sentinel last, Extra &&...extra) { typedef detail::iterator_state state; if (!detail::get_type_info(typeid(state), false)) { @@ -1929,7 +1925,7 @@ template ()).first), typename... Extra> -iterator make_key_iterator(Iterator first, Sentinel last, Extra &&... extra) { +iterator make_key_iterator(Iterator first, Sentinel last, Extra &&...extra) { typedef detail::iterator_state state; if (!detail::get_type_info(typeid(state), false)) { @@ -1958,7 +1954,7 @@ iterator make_key_iterator(Iterator first, Sentinel last, Extra &&... extra) { /// supporting `std::begin()`/`std::end()` template -iterator make_iterator(Type &value, Extra &&... extra) { +iterator make_iterator(Type &value, Extra &&...extra) { return make_iterator(std::begin(value), std::end(value), extra...); } @@ -1966,7 +1962,7 @@ iterator make_iterator(Type &value, Extra &&... extra) { /// supporting `std::begin()`/`std::end()` template -iterator make_key_iterator(Type &value, Extra &&... extra) { +iterator make_key_iterator(Type &value, Extra &&...extra) { return make_key_iterator(std::begin(value), std::end(value), extra...); } @@ -2106,7 +2102,7 @@ NAMESPACE_END(detail) template -void print(Args &&... args) { +void print(Args &&...args) { auto c = detail::collect_arguments(std::forward(args)...); detail::print(c.args(), c.kwargs()); } diff --git a/python/src/pybind11/pytypes.h b/python/src/pybind11/pytypes.h index 933757ad1..ffa17b4d7 100644 --- a/python/src/pybind11/pytypes.h +++ b/python/src/pybind11/pytypes.h @@ -112,12 +112,12 @@ public: template < return_value_policy policy = return_value_policy::automatic_reference, typename... Args> - object operator()(Args &&... args) const; + object operator()(Args &&...args) const; template < return_value_policy policy = return_value_policy::automatic_reference, typename... Args> PYBIND11_DEPRECATED("call(...) was deprecated in favor of operator()(...)") - object call(Args &&... args) const; + object call(Args &&...args) const; /// Equivalent to ``obj is other`` in Python. bool is(object_api const &other) const { @@ -1109,7 +1109,7 @@ public: return std::string(buffer, (size_t)length); } - template str format(Args &&... args) const { + template str format(Args &&...args) const { return attr("format")(std::forward(args)...); } @@ -1282,11 +1282,9 @@ public: template ::value, int> = 0> operator T() const { - return std::is_unsigned::value - ? detail::as_unsigned(m_ptr) - : sizeof(T) <= sizeof(long) - ? (T)PyLong_AsLong(m_ptr) - : (T)PYBIND11_LONG_AS_LONGLONG(m_ptr); + return std::is_unsigned::value ? detail::as_unsigned(m_ptr) + : sizeof(T) <= sizeof(long) ? (T)PyLong_AsLong(m_ptr) + : (T)PYBIND11_LONG_AS_LONGLONG(m_ptr); } }; @@ -1438,7 +1436,7 @@ public: // defer the collector typename collector = detail::deferred_t, Args...>> - explicit dict(Args &&... args) + explicit dict(Args &&...args) : dict(collector(std::forward(args)...).kwargs()) {} size_t size() const { return (size_t)PyDict_Size(m_ptr); } diff --git a/python/src/pybind11/stl.h b/python/src/pybind11/stl.h index 95f890150..bba3c1b0b 100644 --- a/python/src/pybind11/stl.h +++ b/python/src/pybind11/stl.h @@ -356,7 +356,7 @@ struct variant_caster_visitor { /// `boost::variant` and `boost::apply_visitor`. template