reverse.h
Go to the documentation of this file.
1 // HippoMocks, a library for using mocks in unit testing of C++ code.
2 // Copyright (C) 2008, Bas van Tiel, Christian Rexwinkel, Mike Looijmans,
3 // Peter Bindels
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // You can also retrieve it from http://www.gnu.org/licenses/lgpl-2.1.html
20 
21 #ifndef HIPPOMOCKS_REVERSE_H
22 #define HIPPOMOCKS_REVERSE_H
23 
24 #ifdef _MSC_VER
25 #pragma warning(push)
26 #pragma warning(disable: 4510) // MSVC 2013 says: Cannot generate default constructor. This is fine, as we won't use it.
27 #pragma warning(disable: 4512) // MSVC 2013 says: Cannot generate assignment operator. This is fine, as we won't use it.
28 #pragma warning(disable: 4610) // MSVC 2013 says: Cannot create object. It's wrong.
29 #endif
30 template <typename T>
32 {
34 };
35 #ifdef _MSC_VER
36 #pragma warning(pop)
37 #endif
38 
39 template <typename T>
40 auto begin(reversed_container<T> container) -> decltype(container.container.rbegin()) { return container.container.rbegin(); }
41 
42 template <typename T>
43 auto end(reversed_container<T> container) -> decltype(container.container.rend()) { return container.container.rend(); }
44 
45 template <typename T>
46 reversed_container<T> reverse_order(T &container) { return { container }; }
47 
48 #endif
reversed_container< T > reverse_order(T &container)
Definition: reverse.h:46
auto begin(reversed_container< T > container) -> decltype(container.container.rbegin())
Definition: reverse.h:40
auto end(reversed_container< T > container) -> decltype(container.container.rend())
Definition: reverse.h:43