diff --git a/include/pybind11/attr.h b/include/pybind11/attr.h index 7925b8e2..ba4dd841 100644 --- a/include/pybind11/attr.h +++ b/include/pybind11/attr.h @@ -14,18 +14,12 @@ NAMESPACE_BEGIN(pybind11) -template struct arg_t; - /// Annotation for keyword arguments struct arg { constexpr explicit arg(const char *name) : name(name) { } template constexpr arg_t operator=(const T &value) const { return {name, value}; } - template - constexpr arg_t operator=(T const (&value)[N]) const { - return operator=((const T *) value); - } const char *name; }; @@ -33,8 +27,9 @@ struct arg { /// Annotation for keyword arguments with default values template struct arg_t : public arg { constexpr arg_t(const char *name, const T &value, const char *descr = nullptr) - : arg(name), value(value), descr(descr) { } - T value; + : arg(name), value(&value), descr(descr) { } + + const T *value; const char *descr; }; @@ -246,7 +241,7 @@ struct process_attribute> : process_attribute_default> { /* Convert keyword value into a Python object */ object o = object(detail::type_caster::type>::cast( - a.value, return_value_policy::automatic, handle()), false); + *a.value, return_value_policy::automatic, handle()), false); if (!o) { #if !defined(NDEBUG) diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index d25bc383..463f713b 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -17,6 +17,7 @@ NAMESPACE_BEGIN(pybind11) /* A few forward declarations */ class object; class str; class object; class dict; class iterator; +struct arg; template struct arg_t; namespace detail { class accessor; class args_proxy; class kwargs_proxy; } /// Holds a reference to a Python object (no reference counting)