Lines Matching refs:std

88 inline std::pair<decltype(internals::registered_types_py)::iterator, bool> all_type_info_get_cache(PyTypeObject *type);
91 PYBIND11_NOINLINE inline void all_type_info_populate(PyTypeObject *t, std::vector<type_info *> &bases) {
92 std::vector<PyTypeObject *> check;
146 inline const std::vector<detail::type_info *> &all_type_info(PyTypeObject *type) {
169 inline detail::type_info *get_local_type_info(const std::type_index &tp) {
177 inline detail::type_info *get_global_type_info(const std::type_index &tp) {
186 PYBIND11_NOINLINE inline detail::type_info *get_type_info(const std::type_index &tp,
194 std::string tname = tp.name();
201 PYBIND11_NOINLINE inline handle get_type_handle(const std::type_info &tp, bool throw_if_missing) {
265 using type_vec = std::vector<detail::type_info *>;
341 std::string(find_type->type->tp_name) + "' is not a pybind11 base of the given `" +
342 std::string(Py_TYPE(this)->tp_name) + "' instance");
383 if (!nonsimple.values_and_holders) throw std::bad_alloc();
386 if (!nonsimple.values_and_holders) throw std::bad_alloc();
387 std::memset(nonsimple.values_and_holders, 0, space * sizeof(void *));
399 PYBIND11_NOINLINE inline bool isinstance_generic(handle obj, const std::type_info &tp) {
406 PYBIND11_NOINLINE inline std::string error_string() {
414 std::string errorString;
416 errorString += handle(scope.type).attr("__name__").cast<std::string>();
420 errorString += (std::string) str(scope.value);
442 " " + handle(frame->f_code->co_filename).cast<std::string>() +
443 "(" + std::to_string(lineno) + "): " +
444 handle(frame->f_code->co_name).cast<std::string>() + "\n";
485 PYBIND11_NOINLINE type_caster_generic(const std::type_info &type_info)
580 (std::align_val_t) type->type_align);
723 PYBIND11_NOINLINE static std::pair<const void *, const type_info *> src_and_type(
724 const void *src, const std::type_info &cast_type, const std::type_info *rtti_type = nullptr) {
729 std::string tname = rtti_type ? rtti_type->name() : cast_type.name();
731 std::string msg = "Unregistered type : " + tname;
737 const std::type_info *cpptype = nullptr;
750 conditional_t<std::is_pointer<remove_reference_t<T>>::value,
751 typename std::add_pointer<intrinsic_t<T>>::type,
752 typename std::add_lvalue_reference<intrinsic_t<T>>::type>;
763 conditional_t<std::is_pointer<typename std::remove_reference<T>::type>::value,
764 typename std::add_pointer<intrinsic_t<T>>::type,
765 conditional_t<std::is_rvalue_reference<T>::value,
766 typename std::add_rvalue_reference<intrinsic_t<T>>::type,
767 typename std::add_lvalue_reference<intrinsic_t<T>>::type>>;
769 // std::is_copy_constructible isn't quite enough: it lets std::vector<T> (and similar) through when
771 template <typename T, typename SFINAE = void> struct is_copy_constructible : std::is_copy_constructible<T> {};
777 std::is_copy_constructible<Container>,
778 std::is_same<typename Container::value_type &, typename Container::reference>,
780 negation<std::is_same<Container, typename Container::value_type>>
784 // Likewise for std::pair before C++17 (which mandates that the copy constructor not exist when the
786 template <typename T1, typename T2> struct is_copy_constructible<std::pair<T1, T2>>
794 // If so, it sets `tinfo` to point to the std::type_info representing that derived
812 static const void *get(const itype *src, const std::type_info*&) { return src; }
815 struct polymorphic_type_hook<itype, detail::enable_if_t<std::is_polymorphic<itype>::value>>
817 static const void *get(const itype *src, const std::type_info*& type) {
833 explicit type_caster_base(const std::type_info &info) : type_caster_generic(info) { }
848 static std::pair<const void *, const type_info *> src_and_type(const itype *src) {
850 const std::type_info *instance_type = nullptr;
900 template <typename T, typename = enable_if_t<std::is_move_constructible<T>::value>>
901 static auto make_move_constructor(const T *x) -> decltype(new T(std::move(*const_cast<T *>(x))), Constructor{}) {
903 return new T(std::move(*const_cast<T *>(reinterpret_cast<const T *>(arg))));
918 template <typename T> typename make_caster<T>::template cast_op_type<typename std::add_rvalue_reference<T>::type>
920 return std::move(caster).operator
921 typename make_caster<T>::template cast_op_type<typename std::add_rvalue_reference<T>::type>();
924 template <typename type> class type_caster<std::reference_wrapper<type>> {
929 static_assert(std::is_same<typename std::remove_const<type>::type &, subcaster_cast_op_type>::value,
930 "std::reference_wrapper<T> caster requires T to have a caster with an `T &` operator");
934 static handle cast(const std::reference_wrapper<type> &src, return_value_policy policy, handle parent) {
940 template <typename T> using cast_op_type = std::reference_wrapper<type>;
941 operator std::reference_wrapper<type>() { return subcaster.operator subcaster_cast_op_type&(); }
949 template <typename T_, enable_if_t<std::is_same<type, remove_cv_t<T_>>::value, int> = 0> \
953 auto h = cast(std::move(*src), policy, parent); delete src; return h; \
960 operator type&&() && { return std::move(value); } \
965 std::is_same<CharT, char>, /* std::string */
966 std::is_same<CharT, char16_t>, /* std::u16string */
967 std::is_same<CharT, char32_t>, /* std::u32string */
968 std::is_same<CharT, wchar_t> /* std::wstring */
972 struct type_caster<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_type<T>::value>> {
974 using _py_type_1 = conditional_t<std::is_signed<T>::value, _py_type_0, typename std::make_unsigned<_py_type_0>::type>;
975 using py_type = conditional_t<std::is_floating_point<T>::value, double, _py_type_1>;
984 if (std::is_floating_point<T>::value) {
991 } else if (std::is_unsigned<py_type>::value) {
1001 // Protect std::numeric_limits::min/max with parentheses
1002 if (py_err || (std::is_integral<T>::value && sizeof(py_type) != sizeof(T) &&
1003 (py_value < (py_type) (std::numeric_limits<T>::min)() ||
1004 py_value > (py_type) (std::numeric_limits<T>::max)()))) {
1014 auto tmp = reinterpret_steal<object>(std::is_floating_point<T>::value
1028 static typename std::enable_if<std::is_floating_point<U>::value, handle>::type
1034 static typename std::enable_if<!std::is_floating_point<U>::value && std::is_signed<U>::value && (sizeof(U) <= sizeof(long)), handle>::type
1040 static typename std::enable_if<!std::is_floating_point<U>::value && std::is_unsigned<U>::value && (sizeof(U) <= sizeof(unsigned long)), handle>::type
1046 static typename std::enable_if<!std::is_floating_point<U>::value && std::is_signed<U>::value && (sizeof(U) > sizeof(long)), handle>::type
1052 static typename std::enable_if<!std::is_floating_point<U>::value && std::is_unsigned<U>::value && (sizeof(U) > sizeof(unsigned long)), handle>::type
1057 PYBIND11_TYPE_CASTER(T, _<std::is_integral<T>::value>("int", "float"));
1118 template <> class type_caster<std::nullptr_t> : public void_caster<std::nullptr_t> { };
1166 static_assert(!std::is_same<CharT, char>::value || sizeof(CharT) == 1, "Unsupported char size != 1");
1167 static_assert(!std::is_same<CharT, char16_t>::value || sizeof(CharT) == 2, "Unsupported char16_t size != 2");
1168 static_assert(!std::is_same<CharT, char32_t>::value || sizeof(CharT) == 4, "Unsupported char32_t size != 4");
1170 static_assert(!std::is_same<CharT, wchar_t>::value || sizeof(CharT) == 2 || sizeof(CharT) == 4,
1241 // When loading into a std::string or char*, accept a bytes object as-is (i.e.
1247 // We were passed a Python 3 raw bytes; accept it into a std::string or char*
1264 struct type_caster<std::basic_string<CharT, Traits, Allocator>, enable_if_t<is_std_char_type<CharT>::value>>
1265 : string_caster<std::basic_string<CharT, Traits, Allocator>> {};
1269 struct type_caster<std::basic_string_view<CharT, Traits>, enable_if_t<is_std_char_type<CharT>::value>>
1270 : string_caster<std::basic_string_view<CharT, Traits>, true> {};
1273 // Type caster for C-style strings. We basically use a std::string type caster, but also add the
1276 using StringType = std::basic_string<CharT>;
1299 if (std::is_same<char, CharT>::value) {
1360 // Base implementation for std::tuple and std::pair
1378 return cast_impl(std::forward<T>(src), policy, parent, indices{});
1386 operator type() && { return std::move(*this).implicit_cast(indices{}); }
1390 type implicit_cast(index_sequence<Is...>) & { return type(cast_op<Ts>(std::get<Is>(subcasters))...); }
1392 type implicit_cast(index_sequence<Is...>) && { return type(cast_op<Ts>(std::move(std::get<Is>(subcasters)))...); }
1398 for (bool r : {std::get<Is>(subcasters).load(seq[Is], convert)...})
1407 std::array<object, size> entries{{
1408 reinterpret_steal<object>(make_caster<Ts>::cast(std::get<Is>(std::forward<T>(src)), policy, parent))...
1423 template <typename T1, typename T2> class type_caster<std::pair<T1, T2>>
1424 : public tuple_caster<std::pair, T1, T2> {};
1426 template <typename... Ts> class type_caster<std::tuple<Ts...>>
1427 : public tuple_caster<std::tuple, Ts...> {};
1436 /// Type caster for holder types like std::shared_ptr, etc.
1441 static_assert(std::is_base_of<base, type_caster<type>>::value,
1454 explicit operator holder_type*() { return std::addressof(holder); }
1491 template <typename T = holder_type, detail::enable_if_t<!std::is_constructible<T, const T &, type*>::value, int> = 0>
1494 template <typename T = holder_type, detail::enable_if_t<std::is_constructible<T, const T &, type*>::value, int> = 0>
1513 /// Specialize for the common std::shared_ptr, so users don't need to
1515 class type_caster<std::shared_ptr<T>> : public copyable_holder_caster<T, std::shared_ptr<T>> { };
1519 static_assert(std::is_base_of<type_caster_base<type>, type_caster<type>>::value,
1524 return type_caster_base<type>::cast_holder(ptr, std::addressof(src));
1530 class type_caster<std::unique_ptr<type, deleter>>
1531 : public move_only_holder_caster<type, std::unique_ptr<type, deleter>> { };
1540 /// Create a specialization for custom holder types (silently ignores std::shared_ptr)
1552 std::is_base_of<detail::type_caster_holder<base, holder>, detail::type_caster<holder>> {};
1554 template <typename base, typename deleter> struct is_holder_type<base, std::unique_ptr<base, deleter>> :
1555 std::true_type {};
1564 template <typename T = type, enable_if_t<std::is_same<T, handle>::value, int> = 0>
1567 template <typename T = type, enable_if_t<std::is_base_of<object, T>::value, int> = 0>
1594 std::is_void, std::is_pointer, std::is_reference, std::is_const
1596 template <typename T, typename SFINAE = void> struct move_always : std::false_type {};
1600 std::is_move_constructible<T>,
1601 std::is_same<decltype(std::declval<make_caster<T>>().operator T&()), T&>
1602 >::value>> : std::true_type {};
1603 template <typename T, typename SFINAE = void> struct move_if_unreferenced : std::false_type {};
1607 std::is_move_constructible<T>,
1608 std::is_same<decltype(std::declval<make_caster<T>>().operator T&()), T&>
1609 >::value>> : std::true_type {};
1617 (std::is_reference<type>::value || std::is_pointer<type>::value) &&
1618 !std::is_base_of<type_caster_generic, make_caster<type>>::value &&
1619 !std::is_same<intrinsic_t<type>, void>::value
1630 detail::enable_if_t<std::is_base_of<type_caster_generic, make_caster<Return>>::value, void>> {
1632 return !std::is_lvalue_reference<Return>::value &&
1633 !std::is_pointer<Return>::value
1645 (std::string) str(handle.get_type()) + " to C++ type '" + type_id<T>() + "'");
1677 policy = std::is_pointer<T>::value ? return_value_policy::take_ownership : return_value_policy::copy;
1679 policy = std::is_pointer<T>::value ? return_value_policy::reference : return_value_policy::copy;
1693 throw cast_error("Unable to move from Python " + (std::string) str(obj.get_type()) +
1698 T ret = std::move(detail::load_type<T>(obj).operator T&());
1708 return move<T>(std::move(object));
1714 return move<T>(std::move(object));
1721 template <typename T> T object::cast() && { return pybind11::cast<T>(std::move(*this)); }
1729 object object_or_cast(T &&o) { return pybind11::cast(std::forward<T>(o)); }
1747 return pybind11::cast<T>(std::move(o)); }
1760 std::array<object, size> args {
1762 std::forward<Args>(args_), policy, nullptr))... }
1769 std::array<std::string, size> argtypes { {type_id<Args>()...} };
1819 : arg_v(arg(name), std::forward<T>(x), descr) { }
1824 : arg_v(arg(base), std::forward<T>(x), descr) { }
1838 std::string type;
1843 arg_v arg::operator=(T &&value) const { return {std::move(*this), std::forward<T>(value)}; }
1868 std::vector<handle> args;
1871 std::vector<bool> args_convert;
1890 template <typename Arg> using argument_is_args = std::is_same<intrinsic_t<Arg>, args>;
1891 template <typename Arg> using argument_is_kwargs = std::is_same<intrinsic_t<Arg>, kwargs>;
1911 enable_if_t<!std::is_void<Return>::value, Return> call(Func &&f) && {
1912 return std::move(*this).template call_impl<Return>(std::forward<Func>(f), indices{}, Guard{});
1916 enable_if_t<std::is_void<Return>::value, void_type> call(Func &&f) && {
1917 std::move(*this).template call_impl<Return>(std::forward<Func>(f), indices{}, Guard{});
1927 for (bool r : {std::get<Is>(argcasters).load(call.args[Is], call.args_convert[Is])...})
1935 return std::forward<Func>(f)(cast_op<Args>(std::move(std::get<Is>(argcasters)))...);
1938 std::tuple<make_caster<Args>...> argcasters;
1948 : m_args(pybind11::make_tuple<policy>(std::forward<Ts>(values)...)) { }
1953 tuple args() && { return std::move(m_args); }
1976 int _[] = { 0, (process(args_list, std::forward<Ts>(values)), 0)... };
1979 m_args = std::move(args_list);
1985 tuple args() && { return std::move(m_args); }
1986 dict kwargs() && { return std::move(m_kwargs); }
1999 auto o = reinterpret_steal<object>(detail::make_caster<T>::cast(std::forward<T>(x), policy, {}));
2004 argument_cast_error(std::to_string(args_list.size()), type_id<T>());
2060 [[noreturn]] static void nameless_argument_error(std::string type) {
2069 [[noreturn]] static void multiple_values_error(std::string name) {
2078 [[noreturn]] static void argument_cast_error(std::string name, std::string type) {
2092 return simple_collector<policy>(std::forward<Args>(args)...);
2106 return unpacking_collector<policy>(std::forward<Args>(args)...);
2112 return detail::collect_arguments<policy>(std::forward<Args>(args)...).call(derived().ptr());
2118 return operator()<policy>(std::forward<Args>(args)...);