37 #ifdef TSL_RH_NO_EXCEPTIONS
38 #define TSL_RH_CHECK_THROW(S, E)
39 #define TSL_RH_CHECK_THROW_EITHER(S, E1, E2)
41 #define TSL_RH_CHECK_THROW(S, E) BOOST_CHECK_THROW(S, E)
42 #define TSL_RH_CHECK_THROW_EITHER(S, E1, E2) \
47 } catch (const E1&) { \
48 } catch (const E2&) { \
57 return static_cast<std::size_t
>(value);
61 template <
unsigned int MOD>
66 return std::hash<T>()(value) % MOD;
103 stream << *
value.m_value_ptr;
115 return !(lhs == rhs);
143 if (
value.m_value ==
nullptr) {
146 stream << *
value.m_value;
161 return !(lhs == rhs);
167 }
else if (lhs.
m_value ==
nullptr) {
169 }
else if (rhs.
m_value ==
nullptr) {
199 stream <<
value.m_value;
209 return !(lhs == rhs);
226 return std::hash<std::string>()(val.
value());
233 return std::hash<std::string>()(val.
value());
240 return std::hash<std::string>()(val.
value());
247 template <
typename T>
248 static T
get_key(std::size_t counter);
250 template <
typename T>
253 template <
typename HMap>
258 inline std::int32_t utils::get_key<std::int32_t>(std::size_t counter) {
259 return tsl::detail_robin_hash::numeric_cast<std::int32_t>(counter);
263 inline std::int64_t utils::get_key<std::int64_t>(std::size_t counter) {
264 return tsl::detail_robin_hash::numeric_cast<std::int64_t>(counter);
269 std::size_t counter) {
271 tsl::detail_robin_hash::numeric_cast<std::int64_t>(counter));
275 inline std::string utils::get_key<std::string>(std::size_t counter) {
276 return "Key " + std::to_string(counter);
282 tsl::detail_robin_hash::numeric_cast<std::int64_t>(counter));
288 tsl::detail_robin_hash::numeric_cast<std::int64_t>(counter));
292 inline std::int32_t utils::get_value<std::int32_t>(std::size_t counter) {
293 return tsl::detail_robin_hash::numeric_cast<std::int32_t>(counter * 2);
297 inline std::int64_t utils::get_value<std::int64_t>(std::size_t counter) {
298 return tsl::detail_robin_hash::numeric_cast<std::int64_t>(counter * 2);
303 std::size_t counter) {
305 tsl::detail_robin_hash::numeric_cast<std::int64_t>(counter * 2));
309 inline std::string utils::get_value<std::string>(std::size_t counter) {
310 return "Value " + std::to_string(counter);
316 tsl::detail_robin_hash::numeric_cast<std::int64_t>(counter * 2));
322 tsl::detail_robin_hash::numeric_cast<std::int64_t>(counter * 2));
325 template <
typename HMap>
327 using key_t =
typename HMap::key_type;
328 using value_t =
typename HMap::mapped_type;
331 map.reserve(nb_elements);
333 for (std::size_t i = 0; i < nb_elements; i++) {
334 map.insert({utils::get_key<key_t>(i), utils::get_value<value_t>(i)});
343 template <
class T1,
class T2>
361 template <
typename T,
typename U>
369 tsl::detail_robin_hash::numeric_cast<std::uint64_t>(val.size()));
377 template <
class T,
typename std::enable_if<
378 std::is_arithmetic<T>::value>::type* =
nullptr>
380 m_ostream.write(
reinterpret_cast<const char*
>(&val),
sizeof(val));
397 return deserialize_impl<T>();
402 typename std::enable_if<is_pair<T>::value>::type* =
nullptr>
404 auto first = deserialize_impl<typename T::first_type>();
405 return std::make_pair(std::move(first),
406 deserialize_impl<typename T::second_type>());
409 template <
class T,
typename std::enable_if<
410 std::is_same<std::string, T>::value>::type* =
nullptr>
412 const std::size_t str_size =
413 tsl::detail_robin_hash::numeric_cast<std::size_t>(
414 deserialize_impl<std::uint64_t>());
418 std::vector<char> chars(str_size);
424 template <
class T,
typename std::enable_if<std::is_same<
430 template <
class T,
typename std::enable_if<
431 std::is_arithmetic<T>::value>::type* =
nullptr>
434 m_istream.read(
reinterpret_cast<char*
>(&val),
sizeof(val));