Support converting util::blob to util::span explicitly

This commit is contained in:
Nikita Lisitsa 2023-07-06 22:26:11 +03:00
parent b9ed814cfe
commit 2ea0427b0f

View file

@ -1,5 +1,7 @@
#pragma once
#include <psemek/util/span.hpp>
#include <memory>
#include <string>
#include <string_view>
@ -49,6 +51,9 @@ namespace psemek::util
std::string string() const;
std::string_view string_view() const;
util::span<char> span();
util::span<char const> span() const;
private:
std::unique_ptr<char[]> data_;
std::size_t size_ = 0;
@ -125,4 +130,15 @@ namespace psemek::util
{
return std::string_view(data_.get(), size_);
}
inline util::span<char> blob::span()
{
return {data_.get(), size_};
}
inline util::span<char const> blob::span() const
{
return {data_.get(), size_};
}
}