diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2eec3746 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/doc/html/ diff --git a/include/boost/unordered/detail/allocate.hpp b/include/boost/unordered/detail/allocate.hpp index 6671607e..bca63e6a 100644 --- a/include/boost/unordered/detail/allocate.hpp +++ b/include/boost/unordered/detail/allocate.hpp @@ -9,8 +9,9 @@ #ifndef BOOST_UNORDERED_ALLOCATE_HPP #define BOOST_UNORDERED_ALLOCATE_HPP -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include @@ -879,7 +880,7 @@ namespace boost { namespace unordered { namespace detail { namespace func { # define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(n, namespace_) \ template \ void construct_from_tuple_impl( \ - boost::unordered::detail::length<0>, Alloc&, T* ptr, \ + boost::unordered::detail::func::length<0>, Alloc&, T* ptr, \ namespace_ tuple<>) \ { \ new ((void*) ptr) T(); \ @@ -892,7 +893,7 @@ namespace boost { namespace unordered { namespace detail { namespace func { template \ void construct_from_tuple_impl( \ - boost::unordered::detail::length, Alloc&, T* ptr, \ + boost::unordered::detail::func::length, Alloc&, T* ptr, \ namespace_ tuple const& x) \ { \ new ((void*) ptr) T( \ @@ -921,7 +922,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::) void construct_from_tuple(Alloc& alloc, T* ptr, Tuple const& x) { construct_from_tuple_impl( - boost::unordered::detail::length< + boost::unordered::detail::func::length< boost::tuples::length::value>(), alloc, ptr, x); } diff --git a/include/boost/unordered/detail/buckets.hpp b/include/boost/unordered/detail/buckets.hpp index 95d8df18..38c32f5a 100644 --- a/include/boost/unordered/detail/buckets.hpp +++ b/include/boost/unordered/detail/buckets.hpp @@ -7,8 +7,9 @@ #ifndef BOOST_UNORDERED_DETAIL_MANAGER_HPP_INCLUDED #define BOOST_UNORDERED_DETAIL_MANAGER_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/include/boost/unordered/detail/equivalent.hpp b/include/boost/unordered/detail/equivalent.hpp index d1c688b8..d569ad9f 100644 --- a/include/boost/unordered/detail/equivalent.hpp +++ b/include/boost/unordered/detail/equivalent.hpp @@ -7,8 +7,9 @@ #ifndef BOOST_UNORDERED_DETAIL_EQUIVALENT_HPP_INCLUDED #define BOOST_UNORDERED_DETAIL_EQUIVALENT_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/include/boost/unordered/detail/extract_key.hpp b/include/boost/unordered/detail/extract_key.hpp index 92524b54..d68a4a77 100644 --- a/include/boost/unordered/detail/extract_key.hpp +++ b/include/boost/unordered/detail/extract_key.hpp @@ -6,6 +6,11 @@ #ifndef BOOST_UNORDERED_DETAIL_EXTRACT_KEY_HPP_INCLUDED #define BOOST_UNORDERED_DETAIL_EXTRACT_KEY_HPP_INCLUDED +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + #include namespace boost { diff --git a/include/boost/unordered/detail/fwd.hpp b/include/boost/unordered/detail/fwd.hpp index ee8966b7..87c2c23b 100644 --- a/include/boost/unordered/detail/fwd.hpp +++ b/include/boost/unordered/detail/fwd.hpp @@ -6,11 +6,11 @@ #ifndef BOOST_UNORDERED_FWD_HPP_INCLUDED #define BOOST_UNORDERED_FWD_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif - namespace boost { namespace unordered diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index e848b21a..4e92cb41 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -7,6 +7,11 @@ #ifndef BOOST_UNORDERED_DETAIL_ALL_HPP_INCLUDED #define BOOST_UNORDERED_DETAIL_ALL_HPP_INCLUDED +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + #include #include #include diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index 81ac053e..59e6d5d3 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -7,8 +7,9 @@ #ifndef BOOST_UNORDERED_DETAIL_UNIQUE_HPP_INCLUDED #define BOOST_UNORDERED_DETAIL_UNIQUE_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/include/boost/unordered/detail/util.hpp b/include/boost/unordered/detail/util.hpp index 570cf8f8..3428ed7a 100644 --- a/include/boost/unordered/detail/util.hpp +++ b/include/boost/unordered/detail/util.hpp @@ -7,8 +7,9 @@ #ifndef BOOST_UNORDERED_DETAIL_UTIL_HPP_INCLUDED #define BOOST_UNORDERED_DETAIL_UTIL_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index e33dcea2..9b180796 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -9,8 +9,9 @@ #ifndef BOOST_UNORDERED_UNORDERED_MAP_HPP_INCLUDED #define BOOST_UNORDERED_UNORDERED_MAP_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/include/boost/unordered/unordered_map_fwd.hpp b/include/boost/unordered/unordered_map_fwd.hpp index 980bb3ee..1eb26ce9 100644 --- a/include/boost/unordered/unordered_map_fwd.hpp +++ b/include/boost/unordered/unordered_map_fwd.hpp @@ -6,11 +6,11 @@ #ifndef BOOST_UNORDERED_MAP_FWD_HPP_INCLUDED #define BOOST_UNORDERED_MAP_FWD_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif -#include #include #include #include diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 9ba5002f..853b5d73 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -9,8 +9,9 @@ #ifndef BOOST_UNORDERED_UNORDERED_SET_HPP_INCLUDED #define BOOST_UNORDERED_UNORDERED_SET_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/include/boost/unordered/unordered_set_fwd.hpp b/include/boost/unordered/unordered_set_fwd.hpp index 0c8b6d8d..52b9e822 100644 --- a/include/boost/unordered/unordered_set_fwd.hpp +++ b/include/boost/unordered/unordered_set_fwd.hpp @@ -6,11 +6,11 @@ #ifndef BOOST_UNORDERED_SET_FWD_HPP_INCLUDED #define BOOST_UNORDERED_SET_FWD_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif -#include #include #include #include diff --git a/include/boost/unordered_map.hpp b/include/boost/unordered_map.hpp index 00d3c91c..92ef4d60 100644 --- a/include/boost/unordered_map.hpp +++ b/include/boost/unordered_map.hpp @@ -9,8 +9,9 @@ #ifndef BOOST_UNORDERED_MAP_HPP_INCLUDED #define BOOST_UNORDERED_MAP_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/include/boost/unordered_set.hpp b/include/boost/unordered_set.hpp index 98c3ce1d..1c83c02b 100644 --- a/include/boost/unordered_set.hpp +++ b/include/boost/unordered_set.hpp @@ -9,8 +9,9 @@ #ifndef BOOST_UNORDERED_SET_HPP_INCLUDED #define BOOST_UNORDERED_SET_HPP_INCLUDED -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/test/unordered/insert_tests.cpp b/test/unordered/insert_tests.cpp index 59911e12..fb66e2e4 100644 --- a/test/unordered/insert_tests.cpp +++ b/test/unordered/insert_tests.cpp @@ -363,7 +363,6 @@ void equivalent_emplace_tests1(X*, test::random_generator generator) template void move_emplace_tests(X*, test::random_generator generator) { - typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; typedef test::ordered ordered; std::cerr<<"emplace(move(value)) tests for containers with unique keys.\n"; @@ -624,6 +623,8 @@ UNORDERED_AUTO_TEST(insert_initializer_list_set) BOOST_TEST(set2.find({8,7}) == set2.end()); } +#if !BOOST_WORKAROUND(BOOST_MSVC, == 1800) + UNORDERED_AUTO_TEST(insert_initializer_list_multiset) { boost::unordered_multiset multiset; @@ -640,6 +641,8 @@ UNORDERED_AUTO_TEST(insert_initializer_list_multiset) BOOST_TEST_EQ(multiset.count("c"), 0u); } +#endif + UNORDERED_AUTO_TEST(insert_initializer_list_map) { boost::unordered_map map; diff --git a/test/unordered/unnecessary_copy_tests.cpp b/test/unordered/unnecessary_copy_tests.cpp index 2c64bd7c..f2b5e892 100644 --- a/test/unordered/unnecessary_copy_tests.cpp +++ b/test/unordered/unnecessary_copy_tests.cpp @@ -119,6 +119,20 @@ namespace unnecessary_copy_tests } } +// Boost.Move doesn't seem to work very well on this compiler. +// For example for: +// +// T x; +// +// It will default construct T, and then move it in. +// For 'T const' it seems to copy. + +#if defined(__IBMCPP__) && __IBMCPP__ <= 1210 +#define EXTRA_CONSTRUCT_COST 1 +#else +#define EXTRA_CONSTRUCT_COST 0 +#endif + #define COPY_COUNT(n) \ if(::unnecessary_copy_tests::count_copies::copies != n) { \ BOOST_ERROR("Wrong number of copies."); \ @@ -150,9 +164,13 @@ namespace unnecessary_copy_tests BOOST_ERROR("Wrong number of moves."); \ std::cerr \ << "Number of moves: " \ - << ::unnecessary_copy_tests::count_copies::copies \ + << ::unnecessary_copy_tests::count_copies::moves \ << " expecting: [" << a << ", " << b << "]" << std::endl; \ } +#define COPY_COUNT_EXTRA(a, b) \ + COPY_COUNT_RANGE(a, a + b * EXTRA_CONSTRUCT_COST) +#define MOVE_COUNT_EXTRA(a, b) \ + MOVE_COUNT_RANGE(a, a + b * EXTRA_CONSTRUCT_COST) namespace unnecessary_copy_tests { @@ -207,13 +225,29 @@ namespace unnecessary_copy_tests UNORDERED_TEST(unnecessary_copy_emplace_rvalue_test, ((set)(multiset)(map)(multimap))) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template - void unnecessary_copy_emplace_move_test(T*) + void unnecessary_copy_emplace_std_move_test(T*) { reset(); T x; BOOST_DEDUCED_TYPENAME T::value_type a; COPY_COUNT(1); MOVE_COUNT(0); + x.emplace(std::move(a)); + COPY_COUNT(1); MOVE_COUNT(1); + } + + UNORDERED_TEST(unnecessary_copy_emplace_std_move_test, + ((set)(multiset)(map)(multimap))) +#endif + + template + void unnecessary_copy_emplace_boost_move_test(T*) + { + reset(); + T x; + BOOST_DEDUCED_TYPENAME T::value_type a; + COPY_COUNT(1); MOVE_COUNT_EXTRA(0, 1); x.emplace(boost::move(a)); #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) COPY_COUNT(1); MOVE_COUNT(1); @@ -223,7 +257,7 @@ namespace unnecessary_copy_tests #endif } - UNORDERED_TEST(unnecessary_copy_emplace_move_test, + UNORDERED_TEST(unnecessary_copy_emplace_boost_move_test, ((set)(multiset)(map)(multimap))) template @@ -247,10 +281,10 @@ namespace unnecessary_copy_tests T x; COPY_COUNT(0); MOVE_COUNT(0); BOOST_DEDUCED_TYPENAME T::value_type a; - COPY_COUNT(1); MOVE_COUNT(0); + COPY_COUNT(1); MOVE_COUNT_EXTRA(0, 1); x.emplace(boost::move(a)); #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - COPY_COUNT(2); MOVE_COUNT(0); + COPY_COUNT(2); MOVE_COUNT_EXTRA(0, 1); #else COPY_COUNT(1); MOVE_COUNT(1); #endif @@ -364,7 +398,7 @@ namespace unnecessary_copy_tests // TODO: Run tests for pairs without const etc. std::pair a; x.emplace(a); - COPY_COUNT(4); MOVE_COUNT(0); + COPY_COUNT_EXTRA(4, 1); MOVE_COUNT_EXTRA(0, 1); // // 0 arguments @@ -382,7 +416,7 @@ namespace unnecessary_copy_tests // Visual C++ 11 handles calling move for default arguments. COPY_COUNT(3); MOVE_COUNT(1); # else - COPY_COUNT(2); MOVE_COUNT(0); + COPY_COUNT_EXTRA(2, 1); MOVE_COUNT_EXTRA(0, 1); # endif #endif @@ -407,9 +441,8 @@ namespace unnecessary_copy_tests x.emplace(source >()); COPY_COUNT(2); MOVE_COUNT(source_pair_cost); -#if (defined(__GNUC__) && __GNUC__ > 4) || \ - (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 2) || \ - (defined(BOOST_MSVC) && BOOST_MSVC >= 1600 ) +#if !(defined(__GNUC__) && __cplusplus < 199900L) && \ + !(defined(_MSC_VER) && _MSC_VER < 1600) count_copies part; reset(); std::pair a_ref(part, part); @@ -476,8 +509,9 @@ namespace unnecessary_copy_tests COPY_COUNT(tuple_copy_cost); MOVE_COUNT(tuple_move_cost); -#if defined(__GNUC__) && __GNUC__ > 4 || \ - defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 6 +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \ + !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6) && \ + !(defined(BOOST_MSVC) && BOOST_MSVC < 1700) reset(); x.emplace(boost::unordered::piecewise_construct, std::forward_as_tuple(b.first),