Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:50

0001 /*
0002     Copyright (c) 2005-2020 Intel Corporation
0003 
0004     Licensed under the Apache License, Version 2.0 (the "License");
0005     you may not use this file except in compliance with the License.
0006     You may obtain a copy of the License at
0007 
0008         http://www.apache.org/licenses/LICENSE-2.0
0009 
0010     Unless required by applicable law or agreed to in writing, software
0011     distributed under the License is distributed on an "AS IS" BASIS,
0012     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013     See the License for the specific language governing permissions and
0014     limitations under the License.
0015 */
0016 
0017 #ifndef __TBB_range_iterator_H
0018 #define __TBB_range_iterator_H
0019 
0020 #include "../tbb_stddef.h"
0021 
0022 #if __TBB_CPP11_STD_BEGIN_END_PRESENT && __TBB_CPP11_AUTO_PRESENT && __TBB_CPP11_DECLTYPE_PRESENT
0023     #include <iterator>
0024 #endif
0025 
0026 namespace tbb {
0027     // iterators to first and last elements of container
0028     namespace internal {
0029 
0030 #if __TBB_CPP11_STD_BEGIN_END_PRESENT && __TBB_CPP11_AUTO_PRESENT && __TBB_CPP11_DECLTYPE_PRESENT
0031         using std::begin;
0032         using std::end;
0033         template<typename Container>
0034         auto first(Container& c)-> decltype(begin(c))  {return begin(c);}
0035 
0036         template<typename Container>
0037         auto first(const Container& c)-> decltype(begin(c))  {return begin(c);}
0038 
0039         template<typename Container>
0040         auto last(Container& c)-> decltype(begin(c))  {return end(c);}
0041 
0042         template<typename Container>
0043         auto last(const Container& c)-> decltype(begin(c)) {return end(c);}
0044 #else
0045         template<typename Container>
0046         typename Container::iterator first(Container& c) {return c.begin();}
0047 
0048         template<typename Container>
0049         typename Container::const_iterator first(const Container& c) {return c.begin();}
0050 
0051         template<typename Container>
0052         typename Container::iterator last(Container& c) {return c.end();}
0053 
0054         template<typename Container>
0055         typename Container::const_iterator last(const Container& c) {return c.end();}
0056 #endif
0057 
0058         template<typename T, size_t size>
0059         T* first(T (&arr) [size]) {return arr;}
0060 
0061         template<typename T, size_t size>
0062         T* last(T (&arr) [size]) {return arr + size;}
0063     } //namespace internal
0064 }  //namespace tbb
0065 
0066 #endif // __TBB_range_iterator_H