Unordered: Deprecate variadic pair construction emulation.

[SVN r74181]
This commit is contained in:
Daniel James
2011-08-31 22:57:57 +00:00
parent fd1aec2998
commit 1154b5729a
3 changed files with 42 additions and 21 deletions

View File

@ -549,6 +549,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std)
BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
#endif
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
template <typename A, typename B, typename Arg1>
struct emulation1 {
static choice1::type check(choice1, std::pair<A, B> const&);
@ -556,45 +557,58 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
enum { value = sizeof(check(choose(), make<Arg1>())) == sizeof(choice2::type) };
};
#endif
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
template <typename A, typename B, typename Arg1>
struct piecewise3 {
struct check3_base {
static choice1::type check(choice1, boost::unordered::piecewise_construct_t);
static choice2::type check(choice2, A const&);
static choice3::type check(choice3, ...);
};
#else
template <typename A, typename B, typename Arg1>
struct check3_base {
static choice1::type check(choice1, boost::unordered::piecewise_construct_t);
static choice3::type check(choice3, ...);
};
#endif
enum { value = sizeof(check(choose(), make<Arg1>())) == sizeof(choice1::type) };
template <typename A, typename B, typename Arg1>
struct piecewise3 {
enum { value =
sizeof(check3_base<A,B,Arg1>::check(choose(), make<Arg1>())) ==
sizeof(choice1::type) };
};
template <typename A, typename B, typename Arg1>
struct emulation3 {
static choice1::type check(choice1, boost::unordered::piecewise_construct_t);
static choice2::type check(choice2, A const&);
static choice3::type check(choice3, ...);
enum { value = sizeof(check(choose(), make<Arg1>())) == sizeof(choice2::type) };
enum { value =
sizeof(check3_base<A,B,Arg1>::check(choose(), make<Arg1>())) ==
sizeof(choice2::type) };
};
template <typename A, typename B, typename Arg1>
struct normal3 {
static choice1::type check(choice1, boost::unordered::piecewise_construct_t);
static choice2::type check(choice2, A const&);
static choice3::type check(choice3, ...);
enum { value = sizeof(check(choose(), make<Arg1>())) == sizeof(choice3::type) };
enum { value =
sizeof(check3_base<A,B,Arg1>::check(choose(), make<Arg1>())) ==
sizeof(choice3::type) };
};
template <typename T, typename Arg1>
struct pair_construct1 {};
template <typename T, typename Arg1>
struct normal_construct1 { typedef void type; };
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
template <typename A, typename B, typename Arg1>
struct pair_construct1<std::pair<A, B>, Arg1>
: enable_if<emulation1<A, B, Arg1>, void> {};
template <typename T, typename Arg1>
struct normal_construct1 { typedef void type; };
template <typename A, typename B, typename Arg1>
struct normal_construct1<std::pair<A, B>, Arg1>
: disable_if<emulation1<A, B, Arg1>, void> {};
#endif
template <typename T, typename Arg1>
struct piecewise_construct3 {};
@ -616,13 +630,15 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
template <typename T>
struct pair_construct_n {};
template <typename A, typename B>
struct pair_construct_n<std::pair<A, B> > { typedef void type; };
template <typename T>
struct normal_construct_n { typedef void type; };
#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
template <typename A, typename B>
struct pair_construct_n<std::pair<A, B> > { typedef void type; };
template <typename A, typename B>
struct normal_construct_n<std::pair<A, B> > {};
#endif
template <class T>
inline void construct_impl(void* address)

View File

@ -35,6 +35,9 @@ test-suite unordered
[ run move_tests.cpp ]
[ run assign_tests.cpp ]
[ run insert_tests.cpp ]
[ run insert_tests.cpp : :
: <define>BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
: insert_deprecated ]
[ run insert_stable_tests.cpp ]
[ run unnecessary_copy_tests.cpp ]
[ run erase_tests.cpp ]

View File

@ -545,14 +545,15 @@ UNORDERED_AUTO_TEST(map_emplace_test)
BOOST_TEST(x.find(0) != x.end() &&
x.find(0)->second == overloaded_constructor());
x.emplace(1);
BOOST_TEST(x.find(1) != x.end() &&
x.find(1)->second == overloaded_constructor());
x.emplace(2, 3);
BOOST_TEST(x.find(2) != x.end() &&
x.find(2)->second == overloaded_constructor(3));
#if defined (BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
x.emplace(1);
BOOST_TEST(x.find(1) != x.end() &&
x.find(1)->second == overloaded_constructor());
x.emplace(4, 5, 6);
BOOST_TEST(x.find(4) != x.end() &&
x.find(4)->second == overloaded_constructor(5, 6));
@ -560,6 +561,7 @@ UNORDERED_AUTO_TEST(map_emplace_test)
x.emplace(7, 8, 9, 10);
BOOST_TEST(x.find(7) != x.end() &&
x.find(7)->second == overloaded_constructor(8, 9, 10));
#endif
}
UNORDERED_AUTO_TEST(set_emplace_test)