Skip to content

Commit d2e512e

Browse files
committed
Added hash value for boost::basic_string_view for older version of boost.
1 parent 13d5192 commit d2e512e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/mqtt/string_view.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ using std::basic_string_view;
3232
#define MQTT_NO_BOOST_STRING_VIEW 0
3333

3434
#include <boost/utility/string_view.hpp>
35+
#include <boost/container_hash/hash_fwd.hpp>
3536

3637
namespace MQTT_NS {
3738

@@ -40,6 +41,14 @@ using string_view = boost::string_view;
4041
template<class CharT, class Traits = std::char_traits<CharT> >
4142
using basic_string_view = boost::basic_string_view<CharT, Traits>;
4243

44+
#if BOOST_VERSION < 106900
45+
46+
template <class charT, class traits>
47+
std::size_t hash_value(basic_string_view<charT, traits> s) {
48+
return boost::hash_range(s.begin(), s.end());
49+
}
50+
#endif // BOOST_VERSION < 106900
51+
4352
} // namespace MQTT_NS
4453

4554
#else // BOOST_VERSION >= 106100

0 commit comments

Comments
 (0)