Skip to content

Commit

Permalink
protect non-const methods
Browse files Browse the repository at this point in the history
s.t. they aren't public on frozenset
  • Loading branch information
ecatmur authored Apr 19, 2022
1 parent 27986dd commit a56f91c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1787,15 +1787,15 @@ class kwargs : public dict {
class set_base : public object {
protected:
PYBIND11_OBJECT(set_base, object, PyAnySet_Check)

public:
size_t size() const { return (size_t) PySet_Size(m_ptr); }
bool empty() const { return size() == 0; }
template <typename T>
bool add(T &&val) /* py-non-const */ {
return PySet_Add(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 0;
}
void clear() /* py-non-const */ { PySet_Clear(m_ptr); }

public:
size_t size() const { return (size_t) PySet_Size(m_ptr); }
bool empty() const { return size() == 0; }
template <typename T>
bool contains(T &&val) const {
return PySet_Contains(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 1;
Expand Down

0 comments on commit a56f91c

Please sign in to comment.