lokinet/llarp/util/string_view.hpp

34 lines
710 B
C++
Raw Normal View History

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);
2019-04-25 23:21:19 +00:00
}
2018-11-01 12:47:14 +00:00
} // namespace llarp
#endif
#endif