mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-31 15:20:34 +00:00
Add PYBIND11_EXPAND_SIDE_EFFECTS macro
This allows calling of functions (typically void) over a parameter pack, replacing usage such as: bool unused[] = { (voidfunc(param_pack_arg), false)..., false }; (void) unused; with a much cleaner: PYBIND11_EXPAND_SIDE_EFFECTS(voidfunc(param_pack_arg));
This commit is contained in:
parent
4e1e4a580e
commit
926e2cf333
@ -504,6 +504,14 @@ struct is_input_iterator<T, void_t<decltype(*std::declval<T &>()), decltype(++st
|
|||||||
/// Ignore that a variable is unused in compiler warnings
|
/// Ignore that a variable is unused in compiler warnings
|
||||||
inline void ignore_unused(const int *) { }
|
inline void ignore_unused(const int *) { }
|
||||||
|
|
||||||
|
/// Apply a function over each element of a parameter pack
|
||||||
|
#ifdef __cpp_fold_expressions
|
||||||
|
#define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (((PATTERN), void()), ...)
|
||||||
|
#else
|
||||||
|
using expand_side_effects = bool[];
|
||||||
|
#define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) pybind11::detail::expand_side_effects{ ((PATTERN), void(), false)..., false }
|
||||||
|
#endif
|
||||||
|
|
||||||
NAMESPACE_END(detail)
|
NAMESPACE_END(detail)
|
||||||
|
|
||||||
/// Returns a named pointer that is shared among all extension modules (using the same
|
/// Returns a named pointer that is shared among all extension modules (using the same
|
||||||
|
@ -947,8 +947,7 @@ public:
|
|||||||
set_operator_new<type>(&record);
|
set_operator_new<type>(&record);
|
||||||
|
|
||||||
/* Register base classes specified via template arguments to class_, if any */
|
/* Register base classes specified via template arguments to class_, if any */
|
||||||
bool unused[] = { (add_base<options>(record), false)..., false };
|
PYBIND11_EXPAND_SIDE_EFFECTS(add_base<options>(record));
|
||||||
(void) unused;
|
|
||||||
|
|
||||||
/* Process optional arguments, if any */
|
/* Process optional arguments, if any */
|
||||||
process_attributes<Extra...>::init(extra..., &record);
|
process_attributes<Extra...>::init(extra..., &record);
|
||||||
|
Loading…
Reference in New Issue
Block a user