@@ -76,9 +76,6 @@ export namespace CppUtils::Language::JSON
7676 return std::nullopt;
7777 }
7878
79- [[nodiscard]] inline auto operator[](std::string_view key) const -> const Value&;
80- [[nodiscard]] inline auto operator[](std::size_t index) const -> const Value&;
81-
8279 [[nodiscard]] constexpr auto operator==(const Value&) const -> bool = default;
8380
8481 [[nodiscard]] inline operator std::string() const
@@ -88,6 +85,9 @@ export namespace CppUtils::Language::JSON
8885 return result;
8986 }
9087
88+ [[nodiscard]] inline auto operator[](this auto&& self [[lifetimebound]], std::string_view key) -> const Value&;
89+ [[nodiscard]] inline auto operator[](this auto&& self [[lifetimebound]], std::size_t index) -> const Value&;
90+
9191 template<std::output_iterator<char> Iterator>
9292 inline auto dump(Iterator out) const -> Iterator
9393 {
@@ -137,9 +137,9 @@ export namespace CppUtils::Language::JSON
137137
138138 inline constinit const auto nullValue = Value{};
139139
140- [[nodiscard]] inline auto Value::operator[](std::string_view key) const -> const Value&
140+ [[nodiscard]] inline auto Value::operator[](this auto&& self [[lifetimebound]], std::string_view key) -> const Value&
141141 {
142- if (auto object = getIf<Object>())
142+ if (auto object = self.template getIf<Object>())
143143 {
144144 const auto& objectRef = object->get();
145145 if (auto it = objectRef.find(key); it != std::end(objectRef))
@@ -148,9 +148,9 @@ export namespace CppUtils::Language::JSON
148148 return nullValue;
149149 }
150150
151- [[nodiscard]] inline auto Value::operator[](std::size_t index) const -> const Value&
151+ [[nodiscard]] inline auto Value::operator[](this auto&& self [[lifetimebound]], std::size_t index) -> const Value&
152152 {
153- if (auto array = getIf<Array>())
153+ if (auto array = self.template getIf<Array>())
154154 {
155155 const auto& arrayRef = array->get();
156156 if (index < std::size(arrayRef))
0 commit comments