Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
spatial_template_member_swap.hpp
1 // -*- C++ -*-
2 //
3 // Copyright Sylvain Bougerel 2009 - 2013.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file COPYING or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 
14 #ifndef SPATIAL_TEMPLATE_MEMBER_SWAP_HPP
15 #define SPATIAL_TEMPLATE_MEMBER_SWAP_HPP
16 
17 #include <algorithm> // provides: ::std::swap
18 // provides: import::is_empty, import::false_type and import::true_type
19 #include "spatial_import_type_traits.hpp"
20 
21 namespace spatial
22 {
23  namespace details
24  {
26 
29  template<bool, typename Tp>
31  {
32  static void do_it(Tp& left, const Tp& right)
33  { left = right; }
34  };
35 
36  template<typename Tp>
38  { static void do_it(Tp&, const Tp&) { } };
39 
40  template <typename Tp>
42  : template_member_assign_provider<import::is_empty<Tp>::value, Tp>
43  { };
45 
47 
50  template<bool, typename Tp>
52  {
53  static void do_it(Tp& left, Tp& right)
54  {
55  using ::std::swap;
56  swap(left, right);
57  }
58  };
59 
60  template<typename Tp>
62  { static void do_it(Tp&, Tp&) { } };
63 
64  template <typename Tp>
66  : template_member_swap_provider<import::is_empty<Tp>::value, Tp>
67  { };
69  }
70 }
71 
72 #endif // SPATIAL_TEMPLATE_MEMBER_SWAP_HPP
Perform a specialized swap for empty classes.
Perform a specialized assign for empty classes.
The main namespace used in the library.
Definition: algorithm.hpp:23
void swap(Kdtree< Rank, Key, Value, Compare, Alloc > &left, Kdtree< Rank, Key, Value, Compare, Alloc > &right)
Swap the content of the tree left and right.