fix doc example typo
[boost.git] / boost / serialization / detail / get_data.hpp
blob0e9c190295cfbdcbb085c1d517f7f3658f4fc3c3
1 // (C) Copyright 2005 Matthias Troyer
2 // Use, modification and distribution is subject to the Boost Software
3 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 // See http://www.boost.org for updates, documentation, and revision history.
8 #ifndef BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
9 #define BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
11 // MS compatible compilers support #pragma once
12 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
13 # pragma once
14 #endif
16 #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
17 #define STD _STLP_STD
18 #else
19 #define STD std
20 #endif
23 #include <vector>
24 #include <valarray>
26 namespace boost { namespace serialization { namespace detail {
28 template <class T, class Allocator>
29 T* get_data(STD::vector<T,Allocator>& v)
31 return v.empty() ? 0 : &(v[0]);
34 template <class T, class Allocator>
35 T* get_data(STD::vector<T,Allocator> const & v)
37 return get_data(const_cast<STD::vector<T,Allocator>&>(v));
41 template <class T>
42 T* get_data(STD::valarray<T>& v)
44 return v.size()==0 ? 0 : &(v[0]);
47 template <class T>
48 const T* get_data(STD::valarray<T> const& v)
50 return get_data(const_cast<STD::valarray<T>&>(v));
53 } } } //namespace boost::serialization::detail
55 #endif // BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP