00001 /* 00002 * 00003 * Copyright (c) 2002, 2003 Kresimir Fresl, Toon Knapen and Karl Meerbergen 00004 * 00005 * Distributed under the Boost Software License, Version 1.0. 00006 * (See accompanying file LICENSE_1_0.txt or copy at 00007 * http://www.boost.org/LICENSE_1_0.txt) 00008 * 00009 * KF acknowledges the support of the Faculty of Civil Engineering, 00010 * University of Zagreb, Croatia. 00011 * 00012 */ 00013 00014 #ifndef BOOST_NUMERIC_BINDINGS_TRAITS_C_ARRAY_H 00015 #define BOOST_NUMERIC_BINDINGS_TRAITS_C_ARRAY_H 00016 00017 #include <boost/numeric/bindings/traits/config.hpp> 00018 00019 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 00020 00021 #include <boost/numeric/bindings/traits/vector_traits.hpp> 00022 00023 namespace boost { namespace numeric { namespace bindings { namespace traits { 00024 00025 // built-in array 00026 template <typename T, std::size_t N, typename V> 00027 struct vector_detail_traits<T[N], V> { 00028 00029 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK 00030 BOOST_STATIC_ASSERT( 00031 (boost::is_same<T[N], typename boost::remove_const<V>::type>::value) 00032 ); 00033 #endif 00034 00035 typedef T identifier_type [N]; // C++ syntax is amazing ;o) 00036 typedef V vector_type; 00037 typedef T value_type; 00038 typedef typename detail::generate_const<V, T>::type* pointer; 00039 00040 static pointer storage (vector_type& v) { return v; } 00041 static int size (vector_type&) { return N; } 00042 static int stride (vector_type&) { return 1; } 00043 }; 00044 00045 }}}} 00046 00047 #else // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 00048 00049 #error with your compiler plain C array cannot be used in bindings 00050 00051 #endif // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 00052 00053 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_C_ARRAY_H