Skip to content

Commit 64568cc

Browse files
noahbkimwjakob
authored andcommitted
Make str::format const (#1142)
1 parent 9d293cc commit 64568cc

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

docs/api_core.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ Wrapper classes
10851085
*Note*: The C string will be deleted when the `str` instance is garbage
10861086
collected.
10871087

1088-
.. cpp:function:: template <typename... Args> str format(Args&&... args)
1088+
.. cpp:function:: template <typename... Args> str format(Args&&... args) const
10891089

10901090
C++ analog of the Python routine ``str.format``. Can be called with
10911091
positional and keyword arguments.

include/nanobind/nb_accessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ detail::accessor<detail::num_item_tuple> tuple::operator[](T index) const {
250250
return { derived(), (Py_ssize_t) index };
251251
}
252252

253-
template <typename... Args> str str::format(Args&&... args) {
253+
template <typename... Args> str str::format(Args&&... args) const {
254254
return steal<str>(
255255
derived().attr("format")((detail::forward_t<Args>) args...).release());
256256
}

include/nanobind/nb_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ class str : public object {
427427
explicit str(const char *s, size_t n)
428428
: object(detail::str_from_cstr_and_size(s, n), detail::steal_t{}) { }
429429

430-
template <typename... Args> str format(Args&&... args);
430+
template <typename... Args> str format(Args&&... args) const;
431431

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

0 commit comments

Comments
 (0)