BVB Source Codes

mars Show pair.hpp Source code

Return Download mars: download pair.hpp Source code - Download mars Source code - Type:.hpp
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2013.
  4. //
  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)
  8. //
  9. // See http://www.boost.org/libs/container for documentation.
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12.  
  13. #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_PAIR_HPP
  14. #define BOOST_CONTAINER_CONTAINER_DETAIL_PAIR_HPP
  15.  
  16. #ifndef BOOST_CONFIG_HPP
  17. #  include <boost/config.hpp>
  18. #endif
  19.  
  20. #if defined(BOOST_HAS_PRAGMA_ONCE)
  21. #  pragma once
  22. #endif
  23.  
  24. #include <boost/container/detail/config_begin.hpp>
  25. #include <boost/container/detail/workaround.hpp>
  26.  
  27. #include <boost/container/detail/mpl.hpp>
  28. #include <boost/container/detail/type_traits.hpp>
  29. #include <boost/container/detail/mpl.hpp>
  30. #include <boost/container/detail/std_fwd.hpp>
  31. #include <boost/move/adl_move_swap.hpp> //swap
  32.  
  33. #include <boost/intrusive/detail/minimal_pair_header.hpp>      //pair
  34. #include <boost/move/utility_core.hpp>
  35.  
  36. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  37. namespace container {
  38. namespace container_detail {
  39.  
  40. template <class T1, class T2>
  41. struct pair;
  42.  
  43. template <class T>
  44. struct is_pair
  45. {
  46.    static const bool value = false;
  47. };
  48.  
  49. template <class T1, class T2>
  50. struct is_pair< pair<T1, T2> >
  51. {
  52.    static const bool value = true;
  53. };
  54.  
  55. template <class T1, class T2>
  56. struct is_pair< std::pair<T1, T2> >
  57. {
  58.    static const bool value = true;
  59. };
  60.  
  61. template <class T>
  62. struct is_not_pair
  63. {
  64.    static const bool value = !is_pair<T>::value;
  65. };
  66.  
  67. template <class T>
  68. struct is_std_pair
  69. {
  70.    static const bool value = false;
  71. };
  72.  
  73. template <class T1, class T2>
  74. struct is_std_pair< std::pair<T1, T2> >
  75. {
  76.    static const bool value = true;
  77. };
  78.  
  79. struct pair_nat;
  80.  
  81. template <class T1, class T2>
  82. struct pair
  83. {
  84.    private:
  85.    BOOST_COPYABLE_AND_MOVABLE(pair)
  86.  
  87.    public:
  88.    typedef T1 first_type;
  89.    typedef T2 second_type;
  90.  
  91.    T1 first;
  92.    T2 second;
  93.  
  94.    //Default constructor
  95.    pair()
  96.       : first(), second()
  97.    {}
  98.  
  99.    //pair copy assignment
  100.    pair(const pair& x)
  101.       : first(x.first), second(x.second)
  102.    {}
  103.  
  104.    //pair move constructor
  105.    pair(BOOST_RV_REF(pair) p)
  106.       : first(::mars_boost::move(p.first)), second(::mars_boost::move(p.second))
  107.    {}
  108.  
  109.    template <class D, class S>
  110.    pair(const pair<D, S> &p)
  111.       : first(p.first), second(p.second)
  112.    {}
  113.  
  114.    template <class D, class S>
  115.    pair(BOOST_RV_REF_BEG pair<D, S> BOOST_RV_REF_END p)
  116.       : first(::mars_boost::move(p.first)), second(::mars_boost::move(p.second))
  117.    {}
  118.  
  119.    //pair from two values
  120.    pair(const T1 &t1, const T2 &t2)
  121.       : first(t1)
  122.       , second(t2)
  123.    {}
  124.  
  125.    template<class U, class V>
  126.    pair(BOOST_FWD_REF(U) u, BOOST_FWD_REF(V) v)
  127.       : first(::mars_boost::forward<U>(u))
  128.       , second(::mars_boost::forward<V>(v))
  129.    {}
  130.  
  131.    //And now compatibility with std::pair
  132.    pair(const std::pair<T1, T2>& x)
  133.       : first(x.first), second(x.second)
  134.    {}
  135.  
  136.    template <class D, class S>
  137.    pair(const std::pair<D, S>& p)
  138.       : first(p.first), second(p.second)
  139.    {}
  140.  
  141.    pair(BOOST_RV_REF_BEG std::pair<T1, T2> BOOST_RV_REF_END p)
  142.       : first(::mars_boost::move(p.first)), second(::mars_boost::move(p.second))
  143.    {}
  144.  
  145.    template <class D, class S>
  146.    pair(BOOST_RV_REF_BEG std::pair<D, S> BOOST_RV_REF_END p)
  147.       : first(::mars_boost::move(p.first)), second(::mars_boost::move(p.second))
  148.    {}
  149.  
  150.    //piecewise_construct missing
  151.    //template <class U, class V> pair(pair<U, V>&& p);
  152.    //template <class... Args1, class... Args2>
  153.    //   pair(piecewise_construct_t, tuple<Args1...> first_args,
  154.    //        tuple<Args2...> second_args);
  155.  
  156.    //pair copy assignment
  157.    pair& operator=(BOOST_COPY_ASSIGN_REF(pair) p)
  158.    {
  159.       first  = p.first;
  160.       second = p.second;
  161.       return *this;
  162.    }
  163.  
  164.    //pair move assignment
  165.    pair& operator=(BOOST_RV_REF(pair) p)
  166.    {
  167.       first  = ::mars_boost::move(p.first);
  168.       second = ::mars_boost::move(p.second);
  169.       return *this;
  170.    }
  171.  
  172.    template <class D, class S>
  173.    typename ::mars_boost::container::container_detail::disable_if_or
  174.       < pair &
  175.       , ::mars_boost::container::container_detail::is_same<T1, D>
  176.       , ::mars_boost::container::container_detail::is_same<T2, S>
  177.       >::type
  178.       operator=(const pair<D, S>&p)
  179.    {
  180.       first  = p.first;
  181.       second = p.second;
  182.       return *this;
  183.    }
  184.  
  185.    template <class D, class S>
  186.    typename ::mars_boost::container::container_detail::disable_if_or
  187.       < pair &
  188.       , ::mars_boost::container::container_detail::is_same<T1, D>
  189.       , ::mars_boost::container::container_detail::is_same<T2, S>
  190.       >::type
  191.       operator=(BOOST_RV_REF_BEG pair<D, S> BOOST_RV_REF_END p)
  192.    {
  193.       first  = ::mars_boost::move(p.first);
  194.       second = ::mars_boost::move(p.second);
  195.       return *this;
  196.    }
  197. //std::pair copy assignment
  198.    pair& operator=(const std::pair<T1, T2> &p)
  199.    {
  200.       first  = p.first;
  201.       second = p.second;
  202.       return *this;
  203.    }
  204.  
  205.    template <class D, class S>
  206.    pair& operator=(const std::pair<D, S> &p)
  207.    {
  208.       first  = ::mars_boost::move(p.first);
  209.       second = ::mars_boost::move(p.second);
  210.       return *this;
  211.    }
  212.  
  213.    //std::pair move assignment
  214.    pair& operator=(BOOST_RV_REF_BEG std::pair<T1, T2> BOOST_RV_REF_END p)
  215.    {
  216.       first  = ::mars_boost::move(p.first);
  217.       second = ::mars_boost::move(p.second);
  218.       return *this;
  219.    }
  220.  
  221.    template <class D, class S>
  222.    pair& operator=(BOOST_RV_REF_BEG std::pair<D, S> BOOST_RV_REF_END p)
  223.    {
  224.       first  = ::mars_boost::move(p.first);
  225.       second = ::mars_boost::move(p.second);
  226.       return *this;
  227.    }
  228.  
  229.    //swap
  230.    void swap(pair& p)
  231.    {
  232.       ::mars_boost::adl_move_swap(this->first, p.first);
  233.       ::mars_boost::adl_move_swap(this->second, p.second);
  234.    }
  235. };
  236.  
  237. template <class T1, class T2>
  238. inline bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y)
  239. {  return static_cast<bool>(x.first == y.first && x.second == y.second);  }
  240.  
  241. template <class T1, class T2>
  242. inline bool operator< (const pair<T1,T2>& x, const pair<T1,T2>& y)
  243. {  return static_cast<bool>(x.first < y.first ||
  244.                          (!(y.first < x.first) && x.second < y.second)); }
  245.  
  246. template <class T1, class T2>
  247. inline bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  248. {  return static_cast<bool>(!(x == y));  }
  249.  
  250. template <class T1, class T2>
  251. inline bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y)
  252. {  return y < x;  }
  253.  
  254. template <class T1, class T2>
  255. inline bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  256. {  return static_cast<bool>(!(x < y)); }
  257.  
  258. template <class T1, class T2>
  259. inline bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y)
  260. {  return static_cast<bool>(!(y < x)); }
  261.  
  262. template <class T1, class T2>
  263. inline pair<T1, T2> make_pair(T1 x, T2 y)
  264. {  return pair<T1, T2>(x, y); }
  265.  
  266. template <class T1, class T2>
  267. inline void swap(pair<T1, T2>& x, pair<T1, T2>& y)
  268. {  x.swap(y);  }
  269.  
  270. }  //namespace container_detail {
  271. }  //namespace container {
  272.  
  273.  
  274. //Without this specialization recursive flat_(multi)map instantiation fails
  275. //because is_enum needs to instantiate the recursive pair, leading to a compilation error).
  276. //This breaks the cycle clearly stating that pair is not an enum avoiding any instantiation.
  277. template<class T>
  278. struct is_enum;
  279.  
  280. template<class T, class U>
  281. struct is_enum< ::mars_boost::container::container_detail::pair<T, U> >
  282. {
  283.    static const bool value = false;
  284. };
  285.  
  286. template <class T>
  287. struct is_class;
  288.  
  289. //This specialization is needed to avoid instantiation of pair in
  290. //is_class, and allow recursive maps.
  291. template <class T1, class T2>
  292. struct is_class< ::mars_boost::container::container_detail::pair<T1, T2> >
  293. {
  294.    static const bool value = true;
  295. };
  296.  
  297. #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
  298.  
  299. template<class T1, class T2>
  300. struct has_move_emulation_enabled< ::mars_boost::container::container_detail::pair<T1, T2> >
  301. {
  302.    static const bool value = true;
  303. };
  304.  
  305. #endif
  306.  
  307. namespace move_detail{
  308.  
  309. template<class T>
  310. struct is_class_or_union;
  311.  
  312. template <class T1, class T2>
  313. struct is_class_or_union< ::mars_boost::container::container_detail::pair<T1, T2> >
  314. //This specialization is needed to avoid instantiation of pair in
  315. //is_class, and allow recursive maps.
  316. {
  317.    static const bool value = true;
  318. };
  319.  
  320.  
  321. }  //namespace move_detail{
  322.  
  323. }  //namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  324.  
  325. #include <boost/container/detail/config_end.hpp>
  326.  
  327. #endif   //#ifndef BOOST_CONTAINER_DETAIL_PAIR_HPP
  328.  
downloadpair.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top