99
1010#pragma once
1111
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 ) }
1814
1915// Robust support for some features and loading modules compiled against different pybind versions
2016// requires forcing hidden visibility on pybind code, so we enforce this by setting the attribute on
@@ -325,7 +321,7 @@ extern "C" {
325321 void PYBIND11_CONCAT (pybind11_init_, name)(pybind11::module &variable)
326322
327323
328- NAMESPACE_BEGIN (PYBIND11_NAMESPACE)
324+ PYBIND11_NAMESPACE_BEGIN (PYBIND11_NAMESPACE)
329325
330326using ssize_t = Py_ssize_t;
331327using size_t = std::size_t ;
@@ -382,7 +378,7 @@ enum class return_value_policy : uint8_t {
382378 reference_internal
383379};
384380
385- NAMESPACE_BEGIN (detail)
381+ PYBIND11_NAMESPACE_BEGIN (detail)
386382
387383inline static constexpr int log2(size_t n, int k = 0 ) { return (n <= 1 ) ? k : log2 (n >> 1 , k + 1 ); }
388384
@@ -560,7 +556,7 @@ template <typename T, typename... Ts>
560556constexpr size_t constexpr_sum (T n, Ts... ns) { return size_t {n} + constexpr_sum (ns...); }
561557#endif
562558
563- NAMESPACE_BEGIN (constexpr_impl)
559+ PYBIND11_NAMESPACE_BEGIN (constexpr_impl)
564560// / Implementation details for constexpr functions
565561constexpr int first(int i) { return i; }
566562template <typename T, typename ... Ts>
@@ -569,7 +565,7 @@ constexpr int first(int i, T v, Ts... vs) { return v ? i : first(i + 1, vs...);
569565constexpr int last (int /* i*/ , int result) { return result; }
570566template <typename T, typename ... Ts>
571567constexpr 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)
573569
574570// / Return the index of the first type in Ts which satisfies Predicate<T>. Returns sizeof...(Ts) if
575571// / none match.
@@ -683,7 +679,7 @@ using expand_side_effects = bool[];
683679#define PYBIND11_EXPAND_SIDE_EFFECTS (PATTERN ) pybind11::detail::expand_side_effects{ ((PATTERN), void (), false )..., false }
684680#endif
685681
686- NAMESPACE_END (detail)
682+ PYBIND11_NAMESPACE_END (detail)
687683
688684// / C++ bindings of builtin Python exceptions
689685class builtin_exception : public std::runtime_error {
@@ -715,7 +711,7 @@ PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used in
715711
716712template <typename T, typename SFINAE = void > struct format_descriptor { };
717713
718- NAMESPACE_BEGIN (detail)
714+ PYBIND11_NAMESPACE_BEGIN (detail)
719715// Returns the index of the given type in the type char array below, and in the list in numpy.h
720716// The order here is: bool; 8 ints ((signed,unsigned)x(8,16,32,64)bits); float,double,long double;
721717// 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>
728724 std::is_integral<T>::value ? detail::log2(sizeof (T))*2 + std::is_unsigned<T>::value : 8 + (
729725 std::is_same<T, double >::value ? 1 : std::is_same<T, long double >::value ? 2 : 0 ));
730726};
731- NAMESPACE_END (detail)
727+ PYBIND11_NAMESPACE_END (detail)
732728
733729template <typename T> struct format_descriptor<T, detail::enable_if_t<std::is_arithmetic<T>::value>> {
734730 static constexpr const char c = " ?bBhHiIqQfdg" [detail::is_fmt_numeric<T>::index];
@@ -753,7 +749,7 @@ struct error_scope {
753749// / Dummy destructor wrapper that can be used to expose classes with a private destructor
754750struct nodelete { template <typename T> void operator ()(T*) { } };
755751
756- NAMESPACE_BEGIN (detail)
752+ PYBIND11_NAMESPACE_BEGIN (detail)
757753template <typename... Args>
758754struct overload_cast_impl {
759755 constexpr overload_cast_impl () {} // MSVC 2015 needs this
@@ -770,7 +766,7 @@ struct overload_cast_impl {
770766 constexpr auto operator ()(Return (Class::*pmf)(Args...) const , std::true_type) const noexcept
771767 -> decltype (pmf) { return pmf; }
772768};
773- NAMESPACE_END (detail)
769+ PYBIND11_NAMESPACE_END (detail)
774770
775771// overload_cast requires variable templates: C++14
776772#if defined(PYBIND11_CPP14)
@@ -795,7 +791,7 @@ template <typename... Args> struct overload_cast {
795791};
796792#endif // overload_cast
797793
798- NAMESPACE_BEGIN (detail)
794+ PYBIND11_NAMESPACE_BEGIN (detail)
799795
800796// Adaptor for converting arbitrary container arguments into a vector; implicitly convertible from
801797// any standard container (or C-style array) supporting std::begin/std::end, any singleton
@@ -834,8 +830,8 @@ class any_container {
834830 const std::vector<T> *operator ->() const { return &v; }
835831};
836832
837- NAMESPACE_END (detail)
833+ PYBIND11_NAMESPACE_END (detail)
838834
839835
840836
841- NAMESPACE_END (PYBIND11_NAMESPACE)
837+ PYBIND11_NAMESPACE_END (PYBIND11_NAMESPACE)
0 commit comments