Skip to content

Commit 06bd27f

Browse files
committed
import size_t into pybind11 namespace (fixes #498)
1 parent 0780655 commit 06bd27f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/pybind11/common.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
# pragma warning(pop)
9494
#endif
9595

96+
#include <cstddef>
9697
#include <forward_list>
9798
#include <vector>
9899
#include <string>
@@ -182,7 +183,8 @@ extern "C" {
182183

183184
NAMESPACE_BEGIN(pybind11)
184185

185-
typedef Py_ssize_t ssize_t;
186+
using ssize_t = Py_ssize_t;
187+
using size_t = std::size_t;
186188

187189
/// Approach used to cast a previously unknown C++ instance into a Python object
188190
enum class return_value_policy : uint8_t {
@@ -320,7 +322,7 @@ template <typename type, typename holder_type = std::unique_ptr<type>> struct in
320322
};
321323

322324
struct overload_hash {
323-
inline std::size_t operator()(const std::pair<const PyObject *, const char *>& v) const {
325+
inline size_t operator()(const std::pair<const PyObject *, const char *>& v) const {
324326
size_t value = std::hash<const void *>()(v.first);
325327
value ^= std::hash<const void *>()(v.second) + 0x9e3779b9 + (value<<6) + (value>>2);
326328
return value;

0 commit comments

Comments
 (0)