forked from redboltz/mqtt_cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring_view.hpp
78 lines (46 loc) · 1.59 KB
/
string_view.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright Takatoshi Kondo 2016
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(MQTT_STRING_VIEW_HPP)
#define MQTT_STRING_VIEW_HPP
#include <mqtt/namespace.hpp>
#ifdef MQTT_STD_STRING_VIEW
#include <string_view>
namespace MQTT_NS {
using std::string_view;
using std::basic_string_view;
} // namespace MQTT_NS
#else // MQTT_STD_STRING_VIEW
#include <boost/version.hpp>
#if !defined(MQTT_NO_BOOST_STRING_VIEW)
#if BOOST_VERSION >= 106100
#define MQTT_NO_BOOST_STRING_VIEW 0
#include <boost/utility/string_view.hpp>
#include <boost/container_hash/hash_fwd.hpp>
namespace MQTT_NS {
using string_view = boost::string_view;
template<class CharT, class Traits = std::char_traits<CharT> >
using basic_string_view = boost::basic_string_view<CharT, Traits>;
} // namespace MQTT_NS
#if BOOST_VERSION < 106900
namespace boost {
template <class charT, class traits>
std::size_t hash_value(basic_string_view<charT, traits> s) {
return hash_range(s.begin(), s.end());
}
}
#endif // BOOST_VERSION < 106900
#else // BOOST_VERSION >= 106100
#define MQTT_NO_BOOST_STRING_VIEW 1
#include <boost/utility/string_ref.hpp>
namespace MQTT_NS {
using string_view = boost::string_ref;
template<class CharT, class Traits = std::char_traits<CharT> >
using basic_string_view = boost::basic_string_ref<CharT, Traits>;
} // namespace MQTT_NS
#endif // BOOST_VERSION >= 106100
#endif // !defined(MQTT_NO_BOOST_STRING_VIEW)
#endif // !defined(MQTT_STD_STRING_VIEW)
#endif // MQTT_STRING_VIEW_HPP