mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-31 23:30:30 +00:00
Move type_caster_odr_guard to type_caster_odr_guard.h
This commit is contained in:
parent
1acc9d0555
commit
2e6e833929
@ -47,25 +47,8 @@ class type_caster : public type_caster_for_class_<type> {};
|
|||||||
|
|
||||||
#ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_ON
|
#ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_ON
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
template <typename IntrinsicType>
|
|
||||||
struct type_caster_odr_guard : type_caster<IntrinsicType> {
|
|
||||||
static int translation_unit_local;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename IntrinsicType>
|
|
||||||
int type_caster_odr_guard<IntrinsicType>::translation_unit_local = []() {
|
|
||||||
type_caster_odr_guard_impl(typeid(IntrinsicType),
|
|
||||||
type_caster<IntrinsicType>::source_file_line.text,
|
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ODR_GUARD_IMPL_THROW_DISABLED);
|
|
||||||
return 0;
|
|
||||||
}();
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
template <typename type>
|
template <typename type>
|
||||||
using make_caster = type_caster_odr_guard<intrinsic_t<type>>;
|
using make_caster = type_caster_odr_guard<intrinsic_t<type>, type_caster<intrinsic_t<type>>>;
|
||||||
|
|
||||||
#else // !PYBIND11_TYPE_CASTER_ODR_GUARD_ON
|
#else // !PYBIND11_TYPE_CASTER_ODR_GUARD_ON
|
||||||
|
|
||||||
|
@ -106,8 +106,27 @@ constexpr tu_local_descr<N - 1> tu_local_const_name(char const (&text)[N]) {
|
|||||||
}
|
}
|
||||||
constexpr tu_local_descr<0> tu_local_const_name(char const (&)[1]) { return {}; }
|
constexpr tu_local_descr<0> tu_local_const_name(char const (&)[1]) { return {}; }
|
||||||
|
|
||||||
|
struct tu_local_no_data_always_false {
|
||||||
|
operator bool() const noexcept { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
template <typename IntrinsicType, typename TypeCasterType>
|
||||||
|
struct type_caster_odr_guard : TypeCasterType {
|
||||||
|
static tu_local_no_data_always_false translation_unit_local;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename IntrinsicType, typename TypeCasterType>
|
||||||
|
tu_local_no_data_always_false
|
||||||
|
type_caster_odr_guard<IntrinsicType, TypeCasterType>::translation_unit_local
|
||||||
|
= []() {
|
||||||
|
type_caster_odr_guard_impl(typeid(IntrinsicType),
|
||||||
|
TypeCasterType::source_file_line.text,
|
||||||
|
PYBIND11_DETAIL_TYPE_CASTER_ODR_GUARD_IMPL_THROW_DISABLED);
|
||||||
|
return tu_local_no_data_always_false();
|
||||||
|
}();
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_END(detail)
|
PYBIND11_NAMESPACE_END(detail)
|
||||||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user