]> git.sesse.net Git - casparcg/blob - dependencies/boost/boost/polygon/detail/polygon_sort_adaptor.hpp
Manually merged pull request #222
[casparcg] / dependencies / boost / boost / polygon / detail / polygon_sort_adaptor.hpp
1 /*
2   Copyright 2008 Intel Corporation
3  
4   Use, modification and distribution are subject to the Boost Software License,
5   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6   http://www.boost.org/LICENSE_1_0.txt).
7 */
8 #ifndef BOOST_POLYGON_SORT_ADAPTOR_HPP
9 #define BOOST_POLYGON_SORT_ADAPTOR_HPP
10 #ifdef __ICC
11 #pragma warning(disable:2022)
12 #pragma warning(disable:2023)
13 #endif
14
15 #include <algorithm>
16
17 //! @brief gtlsort_adaptor default implementation that calls std::sort
18 namespace boost {
19   namespace polygon {
20
21     template<typename iterator_type>
22     struct dummy_to_delay_instantiation{
23       typedef int unit_type; // default GTL unit 
24     };
25
26     //! @brief gtlsort_adaptor default implementation that calls std::sort
27     template<typename T>
28     struct gtlsort_adaptor {
29       //! @brief wrapper that mimics std::sort() function and takes
30       // the same arguments
31       template<typename RandomAccessIterator_Type>
32       static void sort(RandomAccessIterator_Type _First, 
33                        RandomAccessIterator_Type _Last)
34       {
35          std::sort(_First, _Last);
36       }
37       //! @brief wrapper that mimics std::sort() function overload and takes
38       // the same arguments
39       template<typename RandomAccessIterator_Type, typename Pred_Type>
40       static void sort(RandomAccessIterator_Type _First, 
41                        RandomAccessIterator_Type _Last, 
42                        const Pred_Type& _Comp)
43       {
44          std::sort(_First, _Last, _Comp);
45       }
46     };
47
48     //! @brief user level wrapper for sorting quantities 
49     template <typename iter_type>
50     void gtlsort(iter_type _b_, iter_type _e_) 
51     {
52       gtlsort_adaptor<typename dummy_to_delay_instantiation<iter_type>::unit_type>::sort(_b_, _e_);
53     }
54
55     //! @brief user level wrapper for sorting quantities that takes predicate
56     // as additional argument
57     template <typename iter_type, typename pred_type>
58     void gtlsort(iter_type _b_, iter_type _e_, const pred_type& _pred_) 
59     {
60       gtlsort_adaptor<typename dummy_to_delay_instantiation<iter_type>::unit_type>::sort(_b_, _e_, _pred_);
61     }
62
63
64     
65   } // namespace polygon
66 }   // namespace boost 
67 #endif