-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVector.hxx
More file actions
60 lines (51 loc) · 2.59 KB
/
Vector.hxx
File metadata and controls
60 lines (51 loc) · 2.59 KB
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
/* Copyright 2015, 2016 Robert Haberlach
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) */
#pragma once
#include "impl/BasicVector.hxx"
namespace Constainer {
/**< This is the fundamental class template that provides a 'resizable array'.
Its interface is STD::vector-like. */
template <typename T, STD::size_t MaxN, typename CopyTraits>
class BasicVector :
public detail::BasicVector<T, MaxN, CopyTraits, 0> {
using detail::BasicVector<T, MaxN, CopyTraits, 0>::BasicVector;
};
template <typename T, STD::size_t N1, STD::size_t N2, typename Traits1, typename Traits2>
constexpr void swap( BasicVector<T, N1, Traits1>& lhs, BasicVector<T, N2, Traits2>& rhs ) {
lhs.swap(rhs);
}
// TODO: Implement comparison of BasicVector and Array
template <typename T1, STD::size_t Size1, typename Traits1,
typename T2, STD::size_t Size2, typename Traits2>
constexpr bool operator==(BasicVector<T1, Size1, Traits1> const& lhs, BasicVector<T2, Size2, Traits2> const& rhs) {
return lhs.size() == rhs.size() && Constainer::equal(lhs.begin(), lhs.end(), rhs.begin());
}
template <typename T1, STD::size_t Size1, typename Traits1,
typename T2, STD::size_t Size2, typename Traits2>
constexpr bool operator<(BasicVector<T1, Size1, Traits1> const& lhs, BasicVector<T2, Size2, Traits2> const& rhs) {
return Constainer::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
template <typename T1, STD::size_t Size1, typename Traits1,
typename T2, STD::size_t Size2, typename Traits2>
constexpr bool operator!=(BasicVector<T1, Size1, Traits1> const& lhs, BasicVector<T2, Size2, Traits2> const& rhs) {
return !(lhs == rhs);
}
template <typename T1, STD::size_t Size1, typename Traits1,
typename T2, STD::size_t Size2, typename Traits2>
constexpr bool operator>=(BasicVector<T1, Size1, Traits1> const& lhs, BasicVector<T2, Size2, Traits2> const& rhs) {
return !(lhs < rhs);
}
template <typename T1, STD::size_t Size1, typename Traits1,
typename T2, STD::size_t Size2, typename Traits2>
constexpr bool operator>(BasicVector<T1, Size1, Traits1> const& lhs, BasicVector<T2, Size2, Traits2> const& rhs) {
return rhs < lhs;
}
template <typename T1, STD::size_t Size1, typename Traits1,
typename T2, STD::size_t Size2, typename Traits2>
constexpr bool operator<=(BasicVector<T1, Size1, Traits1> const& lhs, BasicVector<T2, Size2, Traits2> const& rhs) {
return !(lhs > rhs);
}
template <typename T, STD::size_t N=defaultContainerSize>
using Vector = BasicVector<T, N, DefaultCopyTraits<T>>;
}