BRE12
_range_iterator.h
1 /*
2  Copyright 2005-2016 Intel Corporation. All Rights Reserved.
3 
4  This file is part of Threading Building Blocks. Threading Building Blocks is free software;
5  you can redistribute it and/or modify it under the terms of the GNU General Public License
6  version 2 as published by the Free Software Foundation. Threading Building Blocks is
7  distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
8  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9  See the GNU General Public License for more details. You should have received a copy of
10  the GNU General Public License along with Threading Building Blocks; if not, write to the
11  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12 
13  As a special exception, you may use this file as part of a free software library without
14  restriction. Specifically, if other files instantiate templates or use macros or inline
15  functions from this file, or you compile this file and link it with other files to produce
16  an executable, this file does not by itself cause the resulting executable to be covered
17  by the GNU General Public License. This exception does not however invalidate any other
18  reasons why the executable file might be covered by the GNU General Public License.
19 */
20 
21 #ifndef __TBB_range_iterator_H
22 #define __TBB_range_iterator_H
23 
24 #include "../tbb_stddef.h"
25 
26 #if __TBB_CPP11_STD_BEGIN_END_PRESENT && __TBB_CPP11_AUTO_PRESENT && __TBB_CPP11_DECLTYPE_PRESENT
27  #include <iterator>
28 #endif
29 
30 namespace tbb {
31  // iterators to first and last elements of container
32  namespace internal {
33 
34 #if __TBB_CPP11_STD_BEGIN_END_PRESENT && __TBB_CPP11_AUTO_PRESENT && __TBB_CPP11_DECLTYPE_PRESENT
35  using std::begin;
36  using std::end;
37  template<typename Container>
38  auto first(Container& c)-> decltype(begin(c)) {return begin(c);}
39 
40  template<typename Container>
41  auto first(const Container& c)-> decltype(begin(c)) {return begin(c);}
42 
43  template<typename Container>
44  auto last(Container& c)-> decltype(begin(c)) {return end(c);}
45 
46  template<typename Container>
47  auto last(const Container& c)-> decltype(begin(c)) {return end(c);}
48 #else
49  template<typename Container>
50  typename Container::iterator first(Container& c) {return c.begin();}
51 
52  template<typename Container>
53  typename Container::const_iterator first(const Container& c) {return c.begin();}
54 
55  template<typename Container>
56  typename Container::iterator last(Container& c) {return c.end();}
57 
58  template<typename Container>
59  typename Container::const_iterator last(const Container& c) {return c.end();}
60 #endif
61 
62  template<typename T, size_t size>
63  T* first(T (&arr) [size]) {return arr;}
64 
65  template<typename T, size_t size>
66  T* last(T (&arr) [size]) {return arr + size;}
67  } //namespace internal
68 } //namespace tbb
69 
70 #endif // __TBB_range_iterator_H
Definition: _flow_graph_async_msg_impl.h:32
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44