Ticket #7008: get_data.hpp

File get_data.hpp, 1.3 KB (added by dave.lowell@…, 7 years ago)

patched version of get_data.hpp with unconditional undef

Line 
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
25namespace boost {
26namespace serialization {
27namespace detail {
28
29template <class T, class Allocator>
30T* get_data(STD::vector<T,Allocator>& v)
31{
32 return v.empty() ? 0 : &(v[0]);
33}
34
35template <class T, class Allocator>
36T* get_data(STD::vector<T,Allocator> const & v)
37{
38 return get_data(const_cast<STD::vector<T,Allocator>&>(v));
39}
40
41template <class T>
42T* get_data(STD::valarray<T>& v)
43{
44 return v.size()==0 ? 0 : &(v[0]);
45}
46
47template <class T>
48const 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