diff --git a/include/boost/histogram/axis.hpp b/include/boost/histogram/axis.hpp index 1abaf5ba..8d986ba8 100644 --- a/include/boost/histogram/axis.hpp +++ b/include/boost/histogram/axis.hpp @@ -28,11 +28,6 @@ template struct bin { Value value; }; -template <> struct bin { - int idx; - boost::string_ref value; -}; - template struct real_bin { int idx; Value left, right; @@ -510,7 +505,7 @@ private: */ class category_axis : public axis_base, boost::operators { public: - using value_type = const std::string &; + using value_type = boost::string_ref; using const_iterator = axis_iterator; template diff --git a/src/python/axis.cpp b/src/python/axis.cpp index fc15350e..7bdab51a 100644 --- a/src/python/axis.cpp +++ b/src/python/axis.cpp @@ -101,6 +101,14 @@ template python::object axis_getitem(const T &t, int i) { return python::object(t[i]); } +template <> python::object axis_getitem(const category_axis &t, int i) { + if (i == axis_len(t)) { + PyErr_SetString(PyExc_StopIteration, "no more"); + python::throw_error_already_set(); + } + return python::object(t[i].data()); +} + template std::string axis_repr(const T &t) { std::ostringstream os; os << t;