Skip to content

Commit

Permalink
async_string proxy implicit string_view conversion (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenberry authored Jan 2, 2025
1 parent 2377148 commit 910a9f7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/glaze/thread/async_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ namespace glz

public:
proxy(std::string& p, std::unique_lock<std::shared_mutex>&& lock) noexcept : ptr{&p}, lock(std::move(lock)) {}

operator std::string_view() {
return *ptr;
}

std::string* operator->() noexcept { return ptr; }
const std::string* operator->() const noexcept { return ptr; }
Expand All @@ -121,6 +125,10 @@ namespace glz
const_proxy(const std::string& p, std::shared_lock<std::shared_mutex>&& lock) noexcept
: ptr{&p}, lock(std::move(lock))
{}

operator const std::string_view() const {
return *ptr;
}

const std::string* operator->() const noexcept { return ptr; }

Expand Down

0 comments on commit 910a9f7

Please sign in to comment.