X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Flibs%2Fmove%2Ftest%2Forder_type.hpp;h=350312ffb82a9be0f30c0b1bcff0e6aac50ad908;hb=b32b81446b3b05102be0267e79203f59329c1d97;hp=5953cb43b4989e9396c37aa0fd3e5205f7f6e4ae;hpb=215dd7151453fae88e6f968c975b6ce309d42dcf;p=ceph.git diff --git a/ceph/src/boost/libs/move/test/order_type.hpp b/ceph/src/boost/libs/move/test/order_type.hpp index 5953cb43b..350312ffb 100644 --- a/ceph/src/boost/libs/move/test/order_type.hpp +++ b/ceph/src/boost/libs/move/test/order_type.hpp @@ -13,28 +13,29 @@ #define BOOST_MOVE_TEST_ORDER_TYPE_HPP #include +#include #include #include -struct order_type +struct order_perf_type { public: std::size_t key; std::size_t val; - order_type() + order_perf_type() { ++num_elements; } - order_type(const order_type& other) + order_perf_type(const order_perf_type& other) : key(other.key), val(other.val) { ++num_elements; ++num_copy; } - order_type & operator=(const order_type& other) + order_perf_type & operator=(const order_perf_type& other) { ++num_copy; key = other.key; @@ -42,36 +43,81 @@ struct order_type return *this; } - ~order_type () + ~order_perf_type () { --num_elements; } + static void reset_stats() + { + num_compare=0; + num_copy=0; + } + + friend bool operator< (const order_perf_type& left, const order_perf_type& right) + { ++num_compare; return left.key < right.key; } + static boost::ulong_long_type num_compare; static boost::ulong_long_type num_copy; static boost::ulong_long_type num_elements; }; -boost::ulong_long_type order_type::num_compare = 0; -boost::ulong_long_type order_type::num_copy = 0; -boost::ulong_long_type order_type::num_elements = 0; +boost::ulong_long_type order_perf_type::num_compare = 0; +boost::ulong_long_type order_perf_type::num_copy = 0; +boost::ulong_long_type order_perf_type::num_elements = 0; + + +struct order_move_type +{ + BOOST_MOVABLE_BUT_NOT_COPYABLE(order_move_type) + + public: + std::size_t key; + std::size_t val; + + order_move_type() + : key(0u), val(0u) + {} + + order_move_type(BOOST_RV_REF(order_move_type) other) + : key(other.key), val(other.val) + { + other.key = other.val = std::size_t(-1); + } + + order_move_type & operator=(BOOST_RV_REF(order_move_type) other) + { + key = other.key; + val = other.val; + other.key = other.val = std::size_t(-2); + return *this; + } + + friend bool operator< (const order_move_type& left, const order_move_type& right) + { return left.key < right.key; } + + ~order_move_type () + { + key = val = std::size_t(-3); + } +}; -template struct order_type_less { - bool operator()(const T &a,T const &b) const - { ++order_type::num_compare; return a.key < b.key; } + template + bool operator()(const T &a, T const &b) const + { return a < b; } }; template inline bool is_order_type_ordered(T *elements, std::size_t element_count, bool stable = true) { for(std::size_t i = 1; i < element_count; ++i){ - if(order_type_less()(elements[i], elements[i-1])){ + if(order_type_less()(elements[i], elements[i-1])){ std::printf("\n Ord KO !!!!"); return false; } - if( stable && !(order_type_less()(elements[i-1], elements[i])) && (elements[i-1].val > elements[i].val) ){ + if( stable && !(order_type_less()(elements[i-1], elements[i])) && (elements[i-1].val > elements[i].val) ){ std::printf("\n Stb KO !!!! "); return false; } @@ -79,4 +125,45 @@ inline bool is_order_type_ordered(T *elements, std::size_t element_count, bool s return true; } +namespace boost { +namespace movelib { +namespace detail_adaptive { + + + +}}} + +template +inline bool is_key(T *elements, std::size_t element_count) +{ + for(std::size_t i = 1; i < element_count; ++i){ + if(elements[i].key >= element_count){ + std::printf("\n Key.key KO !!!!"); + return false; + } + if(elements[i].val != std::size_t(-1)){ + std::printf("\n Key.val KO !!!!"); + return false; + } + } + return true; +} + +template +inline bool is_buffer(T *elements, std::size_t element_count) +{ + for(std::size_t i = 1; i < element_count; ++i){ + if(elements[i].key != std::size_t(-1)){ + std::printf("\n Buf.key KO !!!!"); + return false; + } + if(elements[i].val >= element_count){ + std::printf("\n Buf.val KO !!!!"); + return false; + } + } + return true; +} + + #endif //BOOST_MOVE_TEST_ORDER_TYPE_HPP