Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62487 - trunk/boost
From: marshall_at_[hidden]
Date: 2010-06-06 12:05:14


Author: marshall
Date: 2010-06-06 12:05:13 EDT (Sun, 06 Jun 2010)
New Revision: 62487
URL: http://svn.boost.org/trac/boost/changeset/62487

Log:
Added get_c_array to Boost.Array
Text files modified:
   trunk/boost/array.hpp | 32 ++++++++++++++++++++++++++++++++
   1 files changed, 32 insertions(+), 0 deletions(-)

Modified: trunk/boost/array.hpp
==============================================================================
--- trunk/boost/array.hpp (original)
+++ trunk/boost/array.hpp 2010-06-06 12:05:13 EDT (Sun, 06 Jun 2010)
@@ -346,6 +346,38 @@
         x.swap(y);
     }
 
+ // Specific for boost::array: simply returns its elems data member.
+ template <typename T, std::size_t N>
+ T(&get_c_array(boost::array<T,N>& arg))[N]
+ {
+ return arg.elems;
+ }
+
+ // Const version.
+ template <typename T, std::size_t N>
+ const T(&get_c_array(const boost::array<T,N>& arg))[N]
+ {
+ return arg.elems;
+ }
+
+#if 0
+ // Overload for std::array, assuming that std::array will have
+ // explicit conversion functions as discussed at the WG21 meeting
+ // in Summit, March 2009.
+ template <typename T, std::size_t N>
+ T(&get_c_array(std::array<T,N>& arg))[N]
+ {
+ return static_cast<T(&)[N]>(arg);
+ }
+
+ // Const version.
+ template <typename T, std::size_t N>
+ const T(&get_c_array(const std::array<T,N>& arg))[N]
+ {
+ return static_cast<T(&)[N]>(arg);
+ }
+#endif
+
 } /* namespace boost */
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk