liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
//  Copyright (c) 2018, Cem Bassoy, cem.bassoy@gmail.com
//
//  Distributed under the Boost Software License, Version 1.0. (See
//  accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
//  The authors gratefully acknowledge the support of
//  Fraunhofer IOSB, Ettlingen Germany
//
 
 
#ifndef _BOOST_STORAGE_TRAITS_HPP_
#define _BOOST_STORAGE_TRAITS_HPP_
 
#include <vector>
#include <array>
 
namespace boost {
namespace numeric {
namespace ublas {
 
 
template <class A>
struct storage_traits;
 
 
template <class V, class A>
struct storage_traits<std::vector<V,A>>
{
    using array_type      = std::vector<V,A>;
 
    using size_type       = typename array_type::size_type;
    using difference_type = typename array_type::difference_type;
    using value_type      = typename array_type::value_type;
 
    using reference       = typename array_type::reference;
    using const_reference = typename array_type::const_reference;
 
    using pointer         = typename array_type::pointer;
    using const_pointer   = typename array_type::const_pointer;
 
    using iterator        = typename array_type::iterator;
    using const_iterator  = typename array_type::const_iterator;
 
    using reverse_iterator        = typename array_type::reverse_iterator;
    using const_reverse_iterator  = typename array_type::const_reverse_iterator;
 
    template<class U>
    using rebind = std::vector<U, typename std::allocator_traits<A>::template rebind_alloc<U>>;
};
 
 
template <class V, std::size_t N>
struct storage_traits<std::array<V,N>>
{
    using array_type      = std::array<V,N>;
 
    using size_type       = typename array_type::size_type;
    using difference_type = typename array_type::difference_type;
    using value_type      = typename array_type::value_type;
 
    using reference       = typename array_type::reference;
    using const_reference = typename array_type::const_reference;
 
    using pointer         = typename array_type::pointer;
    using const_pointer   = typename array_type::const_pointer;
 
    using iterator        = typename array_type::iterator;
    using const_iterator  = typename array_type::const_iterator;
 
    using reverse_iterator        = typename array_type::reverse_iterator;
    using const_reverse_iterator  = typename array_type::const_reverse_iterator;
 
    template<class U>
    using rebind = std::array<U,N>;
};
 
} // ublas
} // numeric
} // boost
 
 
#endif // _BOOST_STORAGE_TRAITS_HPP_