2018-11-01 12:47:14 +00:00
|
|
|
#ifndef LLARP_STRING_VIEW_HPP
|
|
|
|
#define LLARP_STRING_VIEW_HPP
|
|
|
|
|
|
|
|
#if __cplusplus >= 201703L
|
|
|
|
#include <string_view>
|
|
|
|
#include <string>
|
|
|
|
namespace llarp
|
|
|
|
{
|
2019-02-24 02:45:40 +00:00
|
|
|
using string_view = std::string_view;
|
|
|
|
using string_view_hash = std::hash< string_view >;
|
|
|
|
|
2018-11-01 12:47:14 +00:00
|
|
|
static std::string
|
|
|
|
string_view_string(const string_view& v)
|
|
|
|
{
|
|
|
|
return std::string(v.data(), v.size());
|
|
|
|
}
|
|
|
|
} // namespace llarp
|
|
|
|
#else
|
2019-02-24 02:45:40 +00:00
|
|
|
#include <absl/hash/hash.h>
|
|
|
|
#include <absl/strings/string_view.h>
|
2018-11-01 12:47:14 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
2019-02-24 02:45:40 +00:00
|
|
|
using string_view = absl::string_view;
|
|
|
|
using string_view_hash = absl::Hash< string_view >;
|
2018-11-01 12:47:14 +00:00
|
|
|
|
|
|
|
static std::string
|
|
|
|
string_view_string(const string_view& v)
|
|
|
|
{
|
2019-02-24 02:45:40 +00:00
|
|
|
return std::string(v);
|
2018-11-01 12:47:14 +00:00
|
|
|
};
|
|
|
|
} // namespace llarp
|
|
|
|
#endif
|
2018-11-22 23:59:03 +00:00
|
|
|
#endif
|