BWAPI
|
00001 // Copyright (c) 2008 INRIA Sophia-Antipolis (France). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public License as 00006 // published by the Free Software Foundation; version 2.1 of the License. 00007 // See the file LICENSE.LGPL distributed with CGAL. 00008 // 00009 // Licensees holding a valid commercial license may use this file in 00010 // accordance with the commercial license agreement provided with the software. 00011 // 00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00014 // 00015 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/STL_Extension/include/CGAL/array.h $ 00016 // $Id: array.h 50707 2009-07-20 08:52:20Z spion $ 00017 // 00018 // Author(s) : Sylvain Pion 00019 00020 #ifndef CGAL_ARRAY_H 00021 #define CGAL_ARRAY_H 00022 00023 #include <CGAL/config.h> 00024 #ifndef CGAL_CFG_NO_CPP0X_ARRAY 00025 # include <array> 00026 #elif !defined CGAL_CFG_NO_TR1_ARRAY 00027 # include <tr1/array> 00028 #else 00029 # include <boost/array.hpp> 00030 #endif 00031 00032 CGAL_BEGIN_NAMESPACE 00033 00034 namespace cpp0x { 00035 00036 #ifndef CGAL_CFG_NO_CPP0X_ARRAY 00037 using std::array; 00038 #elif !defined CGAL_CFG_NO_TR1_ARRAY 00039 using std::tr1::array; 00040 #else 00041 using boost::array; 00042 #endif 00043 00044 } // cpp0x 00045 00046 00047 // This using is just for short-term backward-compat, people should take the 00048 // habit to use CGAL::cpp0x::array. 00049 using cpp0x::array; 00050 00051 00052 // The make_array() function simply constructs an std::array. 00053 // It is needed for cases where a std::array is used as a class data 00054 // member and you want to initialize it in the member initializers list. 00055 // It is also optimized: no spurious copies of the objects are made, 00056 // provided the compiler does the NRVO. So this is better than 00057 // default construction followed by assignment. 00058 00059 // I proposed it for Boost.Array, but it has not been integrated so far. 00060 // See the thread starting at 00061 // http://lists.boost.org/Archives/boost/2006/08/109003.php 00062 00063 // Hopefully C++0x will fix this properly with initializer_lists. 00064 // So, it's temporary, therefore I do not document it and keep it internal. 00065 00066 #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES 00067 00068 template< typename T, typename... Args > 00069 inline 00070 cpp0x::array< T, 1 + sizeof...(Args) > 00071 make_array(const T & t, const Args & ... args) 00072 { 00073 cpp0x::array< T, 1 + sizeof...(Args) > a = { { t, args... } }; 00074 return a; 00075 } 00076 00077 #else // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES 00078 00079 template < typename T > inline 00080 cpp0x::array<T, 1> 00081 make_array(const T& b1) 00082 { 00083 cpp0x::array<T, 1> a = { { b1 } }; 00084 return a; 00085 } 00086 00087 template < typename T > inline 00088 cpp0x::array<T, 2> 00089 make_array(const T& b1, const T& b2) 00090 { 00091 cpp0x::array<T, 2> a = { { b1, b2 } }; 00092 return a; 00093 } 00094 00095 template < typename T > inline 00096 cpp0x::array<T, 3> 00097 make_array(const T& b1, const T& b2, const T& b3) 00098 { 00099 cpp0x::array<T, 3> a = { { b1, b2, b3 } }; 00100 return a; 00101 } 00102 00103 template < typename T > inline 00104 cpp0x::array<T, 4> 00105 make_array(const T& b1, const T& b2, const T& b3, const T& b4) 00106 { 00107 cpp0x::array<T, 4> a = { { b1, b2, b3, b4 } }; 00108 return a; 00109 } 00110 00111 template < typename T > inline 00112 cpp0x::array<T, 5> 00113 make_array(const T& b1, const T& b2, const T& b3, const T& b4, const T& b5) 00114 { 00115 cpp0x::array<T, 5> a = { { b1, b2, b3, b4, b5 } }; 00116 return a; 00117 } 00118 00119 template < typename T > inline 00120 cpp0x::array<T, 6> 00121 make_array(const T& b1, const T& b2, const T& b3, const T& b4, const T& b5, 00122 const T& b6) 00123 { 00124 cpp0x::array<T, 6> a = { { b1, b2, b3, b4, b5, b6 } }; 00125 return a; 00126 } 00127 00128 #endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES 00129 00130 CGAL_END_NAMESPACE 00131 00132 #endif // CGAL_ARRAY_H