3 // Copyright (c) 2006-2007 Matias Capeletto
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // VC++ 8.0 warns on usage of certain Standard Library and API functions that
10 // can be cause buffer overruns or other possible security issues if misused.
11 // See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
12 // But the wording of the warning is misleading and unsettling, there are no
13 // portable alternative functions, and VC++ 8.0's own libraries use the
14 // functions in question. So turn off the warnings.
15 #define _CRT_SECURE_NO_DEPRECATE
16 #define _SCL_SECURE_NO_DEPRECATE
18 #include <boost/config.hpp>
21 #include <boost/test/minimal.hpp>
24 #include <boost/mpl/list.hpp>
25 #include <boost/type_traits/is_same.hpp>
28 #include <boost/bimap/relation/detail/mutant.hpp>
30 using namespace boost::bimaps::relation::detail;
32 // The mutant idiom is standard if only POD types are used.
34 typedef double type_a;
37 const type_a value_a = 1.4;
38 const type_b value_b = 3;
48 typedef type_a first_type;
49 typedef type_b second_type;
54 struct ReverseStdPairView
56 typedef type_a second_type;
57 typedef type_b first_type;
65 typedef boost::mpl::list< StdPairView, ReverseStdPairView > mutant_views;
67 MutantData(type_a ap, type_b bp) : a(ap), b(bp) {}
73 void test_mutant_basic()
78 MutantData m(value_a,value_b);
80 BOOST_CHECK( sizeof( MutantData ) == sizeof( StdPairView ) );
82 BOOST_CHECK( mutate<StdPairView>(m).first == value_a );
83 BOOST_CHECK( mutate<StdPairView>(m).second == value_b );
84 BOOST_CHECK( mutate<ReverseStdPairView>(m).first == value_b );
85 BOOST_CHECK( mutate<ReverseStdPairView>(m).second == value_a );
87 ReverseStdPairView & rpair = mutate<ReverseStdPairView>(m);
88 rpair.first = value_b;
89 rpair.second = value_a;
91 BOOST_CHECK( mutate<StdPairView>(m).first == value_a );
92 BOOST_CHECK( mutate<StdPairView>(m).second == value_b );
94 BOOST_CHECK( &mutate<StdPairView>(m).first == &m.a );
95 BOOST_CHECK( &mutate<StdPairView>(m).second == &m.b );
99 int test_main( int, char* [] )