Skip to content

Commit

Permalink
Mark c_str() methods of nb::str and nb::bytes as const.
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkinsp committed Aug 25, 2023
1 parent c922753 commit 99aa1ce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/nanobind/nb_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class str : public object {

template <typename... Args> str format(Args&&... args);

const char *c_str() { return PyUnicode_AsUTF8AndSize(m_ptr, nullptr); }
const char *c_str() const { return PyUnicode_AsUTF8AndSize(m_ptr, nullptr); }
};

class bytes : public object {
Expand All @@ -412,7 +412,7 @@ class bytes : public object {
explicit bytes(const char *s, size_t n)
: object(detail::bytes_from_cstr_and_size(s, n), detail::steal_t{}) { }

const char *c_str() { return PyBytes_AsString(m_ptr); }
const char *c_str() const { return PyBytes_AsString(m_ptr); }

size_t size() const { return (size_t) PyBytes_Size(m_ptr); }
};
Expand Down

0 comments on commit 99aa1ce

Please sign in to comment.