From 3ebabcb2d8dcb410544aa6d67b3d2011c5163c6f Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Mon, 12 May 2008 13:29:52 +0000 Subject: [PATCH] Fixed syntax of optional_swap_should_use_default_constructor and swap template specializations that I added 2 days ago (changeset [45265]). Was accepted by MSVC, but rejected by other compilers. [SVN r45295] --- test/optional_test.cpp | 49 +++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/test/optional_test.cpp b/test/optional_test.cpp index a2c9df9..e841194 100644 --- a/test/optional_test.cpp +++ b/test/optional_test.cpp @@ -10,7 +10,7 @@ // fernando_cacciola@hotmail.com // // Revisions: -// 10 May 2008 (added more swap tests) +// 12 May 2008 (added more swap tests) // #include #include @@ -1099,50 +1099,65 @@ namespace optional_swap_test } // End of namespace optional_swap_test. +namespace boost { + // // Compile time tweaking on whether or not swap should use the default constructor: // -template <> struct boost::optional_swap_should_use_default_constructor< - optional_swap_test::class_whose_default_ctor_should_be_used> : boost::mpl::true_ {} ; -template <> struct boost::optional_swap_should_use_default_constructor< - optional_swap_test::class_whose_default_ctor_should_not_be_used> : boost::mpl::false_ {} ; +template <> struct optional_swap_should_use_default_constructor< + optional_swap_test::class_whose_default_ctor_should_be_used> : mpl::true_ {} ; + +template <> struct optional_swap_should_use_default_constructor< + optional_swap_test::class_whose_default_ctor_should_not_be_used> : mpl::false_ {} ; + +template struct optional_swap_should_use_default_constructor< + optional_swap_test::template_whose_default_ctor_should_be_used > : mpl::true_ {} ; -template struct boost::optional_swap_should_use_default_constructor< - optional_swap_test::template_whose_default_ctor_should_be_used > : boost::mpl::true_ {} ; // -// Swap specializations: +// Specialization of boost::swap: // template <> -void boost::swap(boost::optional & x, boost::optional & y) +void swap(optional & x, optional & y) +{ + optional_swap_test::swap(x, y); +} + +} // namespace boost + + +namespace std { + +// +// Specializations of std::swap: +// + +template <> +void swap(optional_swap_test::class_whose_default_ctor_should_be_used & x, optional_swap_test::class_whose_default_ctor_should_be_used & y) { optional_swap_test::swap(x, y); } template <> -void std::swap(optional_swap_test::class_whose_default_ctor_should_be_used & x, optional_swap_test::class_whose_default_ctor_should_be_used & y) +void swap(optional_swap_test::class_whose_default_ctor_should_not_be_used & x, optional_swap_test::class_whose_default_ctor_should_not_be_used & y) { optional_swap_test::swap(x, y); } template <> -void std::swap(optional_swap_test::class_whose_default_ctor_should_not_be_used & x, optional_swap_test::class_whose_default_ctor_should_not_be_used & y) +void swap(optional_swap_test::class_without_default_ctor & x, optional_swap_test::class_without_default_ctor & y) { optional_swap_test::swap(x, y); } template <> -void std::swap(optional_swap_test::class_without_default_ctor & x, optional_swap_test::class_without_default_ctor & y) +void swap(optional_swap_test::class_whose_explicit_ctor_should_be_used & x, optional_swap_test::class_whose_explicit_ctor_should_be_used & y) { optional_swap_test::swap(x, y); } -template <> -void std::swap(optional_swap_test::class_whose_explicit_ctor_should_be_used & x, optional_swap_test::class_whose_explicit_ctor_should_be_used & y) -{ - optional_swap_test::swap(x, y); -} +} // namespace std //