mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-13 01:36:21 +00:00
Add py::dict() keyword constructor
This commit is contained in:
@@ -1148,6 +1148,10 @@ inline object handle::operator()(detail::args_proxy args, detail::kwargs_proxy k
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename... Args, typename /*SFINAE*/>
|
||||
dict::dict(Args &&...args)
|
||||
: dict(detail::unpacking_collector<>(std::forward<Args>(args)...).kwargs()) { }
|
||||
|
||||
#define PYBIND11_MAKE_OPAQUE(Type) \
|
||||
namespace pybind11 { namespace detail { \
|
||||
template<> class type_caster<Type> : public type_caster_base<Type> { }; \
|
||||
|
||||
@@ -589,6 +589,9 @@ public:
|
||||
dict() : object(PyDict_New(), false) {
|
||||
if (!m_ptr) pybind11_fail("Could not allocate dict object!");
|
||||
}
|
||||
template <typename... Args,
|
||||
typename = detail::enable_if_t<detail::all_of_t<detail::is_keyword_or_ds, Args...>::value>>
|
||||
dict(Args &&...args);
|
||||
size_t size() const { return (size_t) PyDict_Size(m_ptr); }
|
||||
detail::dict_iterator begin() const { return (++detail::dict_iterator(*this, 0)); }
|
||||
detail::dict_iterator end() const { return detail::dict_iterator(); }
|
||||
|
||||
Reference in New Issue
Block a user