• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2008-2009: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4    Distributed under the Boost Software License, Version 1.0.
5       (See accompanying file LICENCE.txt or copy at
6            http://www.boost.org/LICENSE_1_0.txt)
7 +-----------------------------------------------------------------------------*/
8 
9 /*-----------------------------------------------------------------------------+
10 Auxiliary functions to reduce redundancies in test case code.
11 +-----------------------------------------------------------------------------*/
12 #ifndef BOOST_ICL_TEST_FUNCTIONS_H_JOFA_091003
13 #define BOOST_ICL_TEST_FUNCTIONS_H_JOFA_091003
14 
15 #include <boost/icl/detail/notate.hpp>
16 #include <boost/icl/type_traits/interval_type_default.hpp>
17 #include <boost/icl/discrete_interval.hpp>
18 
19 #include <boost/icl/type_traits/identity_element.hpp>
20 #include <boost/icl/functors.hpp>
21 #include "portability.hpp"
22 
23 
24 namespace boost{namespace icl
25 {
26 
27 template <class T, class U, class Trt,
28 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
29           ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap,
30 #else
31           ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap,
32 #endif
33           class SequenceT
34 >
itl_map_copy(const SequenceT & segments,ICL_PORT_msvc_7_1_IntervalMap (T,U,Trt)& destination)35 void itl_map_copy(const SequenceT& segments,
36                   ICL_PORT_msvc_7_1_IntervalMap(T,U,Trt)& destination)
37 {
38     ICL_const_FORALL(typename SequenceT, segment_, segments)
39         destination.insert(*segment_);
40 }
41 
42 
43 template <class T, class U, class Trt,
44 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
45           ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap,
46 #else
47           ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap,
48 #endif
49           class SequenceT
50 >
test_interval_map_copy_via_inserter(const SequenceT & segments,ICL_PORT_msvc_7_1_IntervalMap (T,U,Trt)& std_copied_map)51 void test_interval_map_copy_via_inserter(const SequenceT& segments,
52                                          ICL_PORT_msvc_7_1_IntervalMap(T,U,Trt)& std_copied_map)
53 {
54     // The second parameter (std_copied_map) could be omitted and is only held as a
55     // local variable. It is there to help gcc-3.4.4 resolving the function template type.
56     typedef IntervalMap<T,U,Trt> IntervalMapT;
57     IntervalMapT looped_copied_map;
58     std_copied_map.clear();
59     itl_map_copy(segments, looped_copied_map);
60     std::copy(segments.begin(), segments.end(), std::inserter(std_copied_map, std_copied_map.end()));
61     BOOST_CHECK_EQUAL( looped_copied_map, std_copied_map );
62 }
63 
64 }} // namespace icl boost
65 
66 #endif // BOOST_ICL_TEST_FUNCTIONS_H_JOFA_091003
67 
68