Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/utility/swap.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 // Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker | 1 /* |
2 // | 2 * Copyright (c) 2014 Glen Fernandes |
3 // Distributed under the Boost Software License, Version 1.0. (See | 3 * |
4 // accompanying file LICENSE_1_0.txt or copy at | 4 * Distributed under the Boost Software License, Version 1.0. (See |
5 // http://www.boost.org/LICENSE_1_0.txt) | 5 * accompanying file LICENSE_1_0.txt or copy at |
6 // For more information, see http://www.boost.org | 6 * http://www.boost.org/LICENSE_1_0.txt) |
7 | 7 */ |
8 | 8 |
9 #ifndef BOOST_UTILITY_SWAP_HPP | 9 #ifndef BOOST_UTILITY_SWAP_HPP |
10 #define BOOST_UTILITY_SWAP_HPP | 10 #define BOOST_UTILITY_SWAP_HPP |
11 | 11 |
12 // Note: the implementation of this utility contains various workarounds: | 12 // The header file at this path is deprecated; |
13 // - swap_impl is put outside the boost namespace, to avoid infinite | 13 // use boost/core/swap.hpp instead. |
14 // recursion (causing stack overflow) when swapping objects of a primitive | |
15 // type. | |
16 // - swap_impl has a using-directive, rather than a using-declaration, | |
17 // because some compilers (including MSVC 7.1, Borland 5.9.3, and | |
18 // Intel 8.1) don't do argument-dependent lookup when it has a | |
19 // using-declaration instead. | |
20 // - boost::swap has two template arguments, instead of one, to | |
21 // avoid ambiguity when swapping objects of a Boost type that does | |
22 // not have its own boost::swap overload. | |
23 | 14 |
24 #include <algorithm> //for std::swap | 15 #include <boost/core/swap.hpp> |
25 #include <cstddef> //for std::size_t | |
26 | |
27 namespace boost_swap_impl | |
28 { | |
29 template<class T> | |
30 void swap_impl(T& left, T& right) | |
31 { | |
32 using namespace std;//use std::swap if argument dependent lookup fails | |
33 swap(left,right); | |
34 } | |
35 | |
36 template<class T, std::size_t N> | |
37 void swap_impl(T (& left)[N], T (& right)[N]) | |
38 { | |
39 for (std::size_t i = 0; i < N; ++i) | |
40 { | |
41 ::boost_swap_impl::swap_impl(left[i], right[i]); | |
42 } | |
43 } | |
44 } | |
45 | |
46 namespace boost | |
47 { | |
48 template<class T1, class T2> | |
49 void swap(T1& left, T2& right) | |
50 { | |
51 ::boost_swap_impl::swap_impl(left, right); | |
52 } | |
53 } | |
54 | 16 |
55 #endif | 17 #endif |