1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2015-2016.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // See http://www.boost.org/libs/move for documentation.
10 //////////////////////////////////////////////////////////////////////////////
12 #ifndef BOOST_MOVE_TEST_ORDER_TYPE_HPP
13 #define BOOST_MOVE_TEST_ORDER_TYPE_HPP
15 #include <boost/config.hpp>
16 #include <boost/move/core.hpp>
20 struct order_perf_type
31 order_perf_type(const order_perf_type& other)
32 : key(other.key), val(other.val)
38 order_perf_type & operator=(const order_perf_type& other)
51 static void reset_stats()
57 friend bool operator< (const order_perf_type& left, const order_perf_type& right)
58 { ++num_compare; return left.key < right.key; }
60 static boost::ulong_long_type num_compare;
61 static boost::ulong_long_type num_copy;
62 static boost::ulong_long_type num_elements;
65 boost::ulong_long_type order_perf_type::num_compare = 0;
66 boost::ulong_long_type order_perf_type::num_copy = 0;
67 boost::ulong_long_type order_perf_type::num_elements = 0;
70 struct order_move_type
72 BOOST_MOVABLE_BUT_NOT_COPYABLE(order_move_type)
82 order_move_type(BOOST_RV_REF(order_move_type) other)
83 : key(other.key), val(other.val)
85 other.key = other.val = std::size_t(-1);
88 order_move_type & operator=(BOOST_RV_REF(order_move_type) other)
92 other.key = other.val = std::size_t(-2);
96 friend bool operator< (const order_move_type& left, const order_move_type& right)
97 { return left.key < right.key; }
101 key = val = std::size_t(-3);
105 struct order_type_less
108 bool operator()(const T &a, T const &b) const
113 inline bool is_order_type_ordered(T *elements, std::size_t element_count, bool stable = true)
115 for(std::size_t i = 1; i < element_count; ++i){
116 if(order_type_less()(elements[i], elements[i-1])){
117 std::printf("\n Ord KO !!!!");
120 if( stable && !(order_type_less()(elements[i-1], elements[i])) && (elements[i-1].val > elements[i].val) ){
121 std::printf("\n Stb KO !!!! ");
130 namespace detail_adaptive {
137 inline bool is_key(T *elements, std::size_t element_count)
139 for(std::size_t i = 1; i < element_count; ++i){
140 if(elements[i].key >= element_count){
141 std::printf("\n Key.key KO !!!!");
144 if(elements[i].val != std::size_t(-1)){
145 std::printf("\n Key.val KO !!!!");
153 inline bool is_buffer(T *elements, std::size_t element_count)
155 for(std::size_t i = 1; i < element_count; ++i){
156 if(elements[i].key != std::size_t(-1)){
157 std::printf("\n Buf.key KO !!!!");
160 if(elements[i].val >= element_count){
161 std::printf("\n Buf.val KO !!!!");
169 #endif //BOOST_MOVE_TEST_ORDER_TYPE_HPP