array.hpp

Go to the documentation of this file.
00001 /****
00002 ***** Copyright 2010 Intel Corporation All Rights Reserved.
00003 *****
00004 ***** The source code, information and material contained herein are owned by Intel Corporation or its suppliers  *****
00005 ***** or licensors, and title to such Material remains with Intel Corporation or its suppliers or licensors.      *****
00006 ***** The Material contains proprietary information of Intel or its suppliers and licensors. The Material is      *****
00007 ***** protected by worldwide copyright laws and treaty provisions. No part of the Material may be used, copied,   *****
00008 ***** reproduced, modified, published, uploaded, posted, transmitted, distributed or disclosed in any way without *****
00009 ***** Intel's prior express written permission.
00010 *****
00011 ***** No license under any patent, copyright or other intellectual property rights in the material is granted to  *****
00012 ***** or conferred upon you, either expressly, by implication, inducement, estoppel or otherwise. Any license     *****
00013 ***** under such intellectual property rights must be express and approved by Intel in writing.
00014 ****/
00015 
00016 /**** Copyright Ends ****/
00017 
00018 #ifndef ARBB_CPP_ARRAY_HPP
00019 #define ARBB_CPP_ARRAY_HPP
00020 
00021 #include "namespace.hpp"
00022 #include "type_traits.hpp"
00023 #include <iterator>
00024 #include <cstddef>
00025 
00026 #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2 && !__INTEL_COMPILER
00027 # pragma GCC diagnostic ignored "-Wmissing-braces"
00028 #endif
00029 
00030 
00031 namespace ARBB_CPP_NS {
00032 
00035 
00074 template <typename T, std::size_t N>
00075 struct array {
00077   typedef std::size_t size_type;
00079   typedef std::ptrdiff_t difference_type;
00080 
00082   typedef T value_type;
00085   typedef T& reference;
00088   typedef const T& const_reference;
00091   typedef T* pointer;
00094   typedef const T* const_pointer;
00095 
00097   typedef T* iterator;
00099   typedef const T* const_iterator;
00100 
00103   typedef std::reverse_iterator<iterator> reverse_iterator;
00106   typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00107 
00109   void fill(const T& t);
00112   void assign(const T& t);
00116   void swap(array& other);
00117 
00120   iterator begin();
00123   const_iterator begin() const;
00125   iterator end();
00127   const_iterator end() const;
00128 
00131   reverse_iterator rbegin();
00135   const_reverse_iterator rbegin() const;
00138   reverse_iterator rend();
00141   const_reverse_iterator rend() const;
00142 
00144   const_iterator cbegin() const;
00146   const_iterator cend() const;
00148   const_reverse_iterator crbegin() const;
00150   const_reverse_iterator crend() const;
00151 
00154   size_type size() const;
00157   size_type max_size() const;
00159   bool empty() const;
00160 
00164   reference operator[](size_type i);
00168   const_reference operator[](size_type i) const;
00169 
00173   reference at(size_type i);
00177   const_reference at(size_type i) const;
00178 
00182   reference front();
00186   const_reference front() const;
00187 
00190   reference back();
00194   const_reference back() const;
00195 
00198   T* data();
00201   const T* data() const;
00202 
00206   template <typename S>
00207   array<S, N> as() const;
00208 
00211   template <typename U>
00212   const array& operator>>=(const array<U, N>& a);
00213 
00216   template <typename U>
00217   const array& operator<<=(const array<U, N>& a);
00218 
00220 
00221   T m_data[0 != N ? N : 1];
00222 
00224 
00225 };
00226 
00228 template <typename T, std::size_t N>
00229 void swap(array<T, N>& a, array<T, N>& b);
00230 
00232 template <std::size_t N, typename T>
00233 array<T, N> make_array(const T& t);
00234 
00236 
00237 } // namespace ARBB_CPP_NS
00238 
00239 
00240 namespace std {
00241 
00244 template <typename T, std::size_t N>
00245 void swap(ARBB_CPP_NS::array<T, N>& a, ARBB_CPP_NS::array<T, N>& b);
00246 
00247 } // namespace std
00248 
00249 #endif // ARBB_CPP_ARRAY_HPP

Submit feedback on this help topic

Copyright © 2010, Intel Corporation. All rights reserved.