Skip to content

Commit

Permalink
Revert "Add PYBIND11_CONSTINIT, but it does not work for the curren…
Browse files Browse the repository at this point in the history
…t use cases:"

This reverts commit f07b28b.
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Oct 9, 2023
1 parent f07b28b commit 36be645
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions include/pybind11/numpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ class array; // Forward declaration

PYBIND11_NAMESPACE_BEGIN(detail)

#ifndef PYBIND11_CONSTINIT
# if __cplusplus >= 202002L
# define PYBIND11_CONSTINIT constinit
# else
# define PYBIND11_CONSTINIT
# endif
#endif

// Main author of this class: jbms@
template <typename T>
class LazyInitializeAtLeastOnceDestroyNever {
Expand Down Expand Up @@ -255,7 +247,7 @@ struct npy_api {
};

static npy_api &get() {
PYBIND11_CONSTINIT static LazyInitializeAtLeastOnceDestroyNever<npy_api> api_init;
static LazyInitializeAtLeastOnceDestroyNever<npy_api> api_init;
return api_init.Get(lookup);
}

Expand Down Expand Up @@ -693,8 +685,7 @@ class dtype : public object {

private:
static object &_dtype_from_pep3118() {
PYBIND11_CONSTINIT static detail::LazyInitializeAtLeastOnceDestroyNever<object>
imported_obj;
static detail::LazyInitializeAtLeastOnceDestroyNever<object> imported_obj;
return imported_obj.Get([]() {
return detail::import_numpy_core_submodule("_internal").attr("_dtype_from_pep3118");
});
Expand Down

0 comments on commit 36be645

Please sign in to comment.