9
9
10
10
#pragma once
11
11
12
- #if !defined(NAMESPACE_BEGIN)
13
- # define NAMESPACE_BEGIN (name ) namespace name {
14
- #endif
15
- #if !defined(NAMESPACE_END)
16
- # define NAMESPACE_END (name ) }
17
- #endif
12
+ #define PYBIND11_NAMESPACE_BEGIN (name ) namespace name {
13
+ #define PYBIND11_NAMESPACE_END (name ) }
18
14
19
15
// Robust support for some features and loading modules compiled against different pybind versions
20
16
// requires forcing hidden visibility on pybind code, so we enforce this by setting the attribute on
@@ -325,7 +321,7 @@ extern "C" {
325
321
void PYBIND11_CONCAT (pybind11_init_, name)(pybind11::module &variable)
326
322
327
323
328
- NAMESPACE_BEGIN (PYBIND11_NAMESPACE)
324
+ PYBIND11_NAMESPACE_BEGIN (PYBIND11_NAMESPACE)
329
325
330
326
using ssize_t = Py_ssize_t;
331
327
using size_t = std::size_t ;
@@ -382,7 +378,7 @@ enum class return_value_policy : uint8_t {
382
378
reference_internal
383
379
};
384
380
385
- NAMESPACE_BEGIN (detail)
381
+ PYBIND11_NAMESPACE_BEGIN (detail)
386
382
387
383
inline static constexpr int log2(size_t n, int k = 0 ) { return (n <= 1 ) ? k : log2 (n >> 1 , k + 1 ); }
388
384
@@ -560,7 +556,7 @@ template <typename T, typename... Ts>
560
556
constexpr size_t constexpr_sum (T n, Ts... ns) { return size_t {n} + constexpr_sum (ns...); }
561
557
#endif
562
558
563
- NAMESPACE_BEGIN (constexpr_impl)
559
+ PYBIND11_NAMESPACE_BEGIN (constexpr_impl)
564
560
// / Implementation details for constexpr functions
565
561
constexpr int first(int i) { return i; }
566
562
template <typename T, typename ... Ts>
@@ -569,7 +565,7 @@ constexpr int first(int i, T v, Ts... vs) { return v ? i : first(i + 1, vs...);
569
565
constexpr int last (int /* i*/ , int result) { return result; }
570
566
template <typename T, typename ... Ts>
571
567
constexpr int last (int i, int result, T v, Ts... vs) { return last (i + 1 , v ? i : result, vs...); }
572
- NAMESPACE_END (constexpr_impl)
568
+ PYBIND11_NAMESPACE_END (constexpr_impl)
573
569
574
570
// / Return the index of the first type in Ts which satisfies Predicate<T>. Returns sizeof...(Ts) if
575
571
// / none match.
@@ -683,7 +679,7 @@ using expand_side_effects = bool[];
683
679
#define PYBIND11_EXPAND_SIDE_EFFECTS (PATTERN ) pybind11::detail::expand_side_effects{ ((PATTERN), void (), false )..., false }
684
680
#endif
685
681
686
- NAMESPACE_END (detail)
682
+ PYBIND11_NAMESPACE_END (detail)
687
683
688
684
// / C++ bindings of builtin Python exceptions
689
685
class builtin_exception : public std::runtime_error {
@@ -715,7 +711,7 @@ PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used in
715
711
716
712
template <typename T, typename SFINAE = void > struct format_descriptor { };
717
713
718
- NAMESPACE_BEGIN (detail)
714
+ PYBIND11_NAMESPACE_BEGIN (detail)
719
715
// Returns the index of the given type in the type char array below, and in the list in numpy.h
720
716
// The order here is: bool; 8 ints ((signed,unsigned)x(8,16,32,64)bits); float,double,long double;
721
717
// complex float,double,long double. Note that the long double types only participate when long
@@ -728,7 +724,7 @@ template <typename T> struct is_fmt_numeric<T, enable_if_t<std::is_arithmetic<T>
728
724
std::is_integral<T>::value ? detail::log2(sizeof (T))*2 + std::is_unsigned<T>::value : 8 + (
729
725
std::is_same<T, double >::value ? 1 : std::is_same<T, long double >::value ? 2 : 0 ));
730
726
};
731
- NAMESPACE_END (detail)
727
+ PYBIND11_NAMESPACE_END (detail)
732
728
733
729
template <typename T> struct format_descriptor<T, detail::enable_if_t<std::is_arithmetic<T>::value>> {
734
730
static constexpr const char c = " ?bBhHiIqQfdg" [detail::is_fmt_numeric<T>::index ];
@@ -753,7 +749,7 @@ struct error_scope {
753
749
// / Dummy destructor wrapper that can be used to expose classes with a private destructor
754
750
struct nodelete { template <typename T> void operator ()(T*) { } };
755
751
756
- NAMESPACE_BEGIN (detail)
752
+ PYBIND11_NAMESPACE_BEGIN (detail)
757
753
template <typename... Args>
758
754
struct overload_cast_impl {
759
755
constexpr overload_cast_impl () {} // MSVC 2015 needs this
@@ -770,7 +766,7 @@ struct overload_cast_impl {
770
766
constexpr auto operator ()(Return (Class::*pmf)(Args...) const , std::true_type) const noexcept
771
767
-> decltype (pmf) { return pmf; }
772
768
};
773
- NAMESPACE_END (detail)
769
+ PYBIND11_NAMESPACE_END (detail)
774
770
775
771
// overload_cast requires variable templates: C++14
776
772
#if defined(PYBIND11_CPP14)
@@ -795,7 +791,7 @@ template <typename... Args> struct overload_cast {
795
791
};
796
792
#endif // overload_cast
797
793
798
- NAMESPACE_BEGIN (detail)
794
+ PYBIND11_NAMESPACE_BEGIN (detail)
799
795
800
796
// Adaptor for converting arbitrary container arguments into a vector; implicitly convertible from
801
797
// any standard container (or C-style array) supporting std::begin/std::end, any singleton
@@ -834,8 +830,8 @@ class any_container {
834
830
const std::vector<T> *operator ->() const { return &v; }
835
831
};
836
832
837
- NAMESPACE_END (detail)
833
+ PYBIND11_NAMESPACE_END (detail)
838
834
839
835
840
836
841
- NAMESPACE_END (PYBIND11_NAMESPACE)
837
+ PYBIND11_NAMESPACE_END (PYBIND11_NAMESPACE)
0 commit comments