| 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)
|
|---|
| 5 |
|
|---|
| 6 | // See http://www.boost.org for updates, documentation, and revision history.
|
|---|
| 7 |
|
|---|
| 8 | #ifndef BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
|
|---|
| 9 | #define BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
|
|---|
| 10 |
|
|---|
| 11 | // MS compatible compilers support #pragma once
|
|---|
| 12 | #if defined(_MSC_VER)
|
|---|
| 13 | # pragma once
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
|---|
| 17 | #define STD _STLP_STD
|
|---|
| 18 | #else
|
|---|
| 19 | #define STD std
|
|---|
| 20 | #endif
|
|---|
| 21 |
|
|---|
| 22 | #include <vector>
|
|---|
| 23 | #include <valarray>
|
|---|
| 24 |
|
|---|
| 25 | namespace boost {
|
|---|
| 26 | namespace serialization {
|
|---|
| 27 | namespace detail {
|
|---|
| 28 |
|
|---|
| 29 | template <class T, class Allocator>
|
|---|
| 30 | T* get_data(STD::vector<T,Allocator>& v)
|
|---|
| 31 | {
|
|---|
| 32 | return v.empty() ? 0 : &(v[0]);
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | template <class T, class Allocator>
|
|---|
| 36 | T* get_data(STD::vector<T,Allocator> const & v)
|
|---|
| 37 | {
|
|---|
| 38 | return get_data(const_cast<STD::vector<T,Allocator>&>(v));
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | template <class T>
|
|---|
| 42 | T* get_data(STD::valarray<T>& v)
|
|---|
| 43 | {
|
|---|
| 44 | return v.size()==0 ? 0 : &(v[0]);
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | template <class T>
|
|---|
| 48 | const T* get_data(STD::valarray<T> const& v)
|
|---|
| 49 | {
|
|---|
| 50 | return get_data(const_cast<STD::valarray<T>&>(v));
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | } // detail
|
|---|
| 54 | } // serialization
|
|---|
| 55 | } // boost
|
|---|
| 56 |
|
|---|
| 57 | #undef STD
|
|---|
| 58 |
|
|---|
| 59 | #endif // BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
|
|---|