Skip to content

Commit 4c4f19b

Browse files
authored
Update any_str_ops.hpp
add support for std::string_view
1 parent d6f6ba8 commit 4c4f19b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

rtb/datacache/any_str_ops.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ namespace boost {
2828
#endif
2929

3030
#include <string>
31+
#include <string_view>
3132

3233
namespace ufw {
3334

3435
/**
3536
* Functor for containers transparent across `std::string`,
36-
* `boost::container::string`, `boost::string_view`, and `char const*`.
37+
* `boost::container::string`, `boost::string_view`, `std::string_view` and `char const*`.
3738
*/
3839
template<typename Alloc, typename Op>
3940
struct any_str_op {
@@ -48,11 +49,13 @@ namespace ufw {
4849
using shm_str_t = typename boost::container::basic_string<char_t, char_traits_t, Alloc>;
4950
using std_str_t = std::basic_string<char_t, char_traits_t, std::allocator<char_t>>;
5051
using str_view_t = boost::basic_string_view<char_t, char_traits_t>;
52+
using std_str_view_t = std::basic_string_view<char_t, char_traits_t>;
5153

5254
static str_view_t view(char_t const* x) { return {x}; }
5355
static str_view_t view(shm_str_t const& x) { return {x.data(), x.size()}; }
5456
static str_view_t view(std_str_t const& x) { return {x}; }
5557
static str_view_t view(str_view_t x) { return x; }
58+
static str_view_t view(std_str_view_t const& x) { return {x.data(), x.size()}; }
5659
};
5760

5861
template <typename Alloc>

0 commit comments

Comments
 (0)