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
|
//
// Copyright (c) 2018 James E. King III
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
//
// std::hash support for uuid
//
#include <boost/config.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/uuid/string_generator.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_hash.hpp>
#include <iostream>
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
#include <unordered_set>
#endif
int main(int, char*[])
{
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
using namespace boost::uuids;
string_generator gen;
uuid u1 = gen("01234567-89AB-CDEF-0123-456789abcdef");
uuid u2 = gen("fedcba98-7654-3210-fedc-ba9876543210");
std::hash<uuid> hasher;
BOOST_TEST(hasher(u1) != hasher(u2));
std::unordered_set<boost::uuids::uuid> uns;
uns.insert(u1);
uns.insert(u2);
BOOST_TEST_EQ(uns.size(), 2);
return boost::report_errors();
#else
std::cout << "test skipped - no library support for std::hash or std::unordered_set" << std::endl;
return 0;
#endif
}
|