source: mainline/uspace/lib/cpp/include/impl/vector.hpp@ 289b2dd

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 289b2dd was 289b2dd, checked in by Dzejrou <dzejrou@…>, 7 years ago

cpp: started working on vector

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 * Copyright (c) 2017 Jaroslav Jindrak
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef LIBCPP_VECTOR
30#define LIBCPP_VECTOR
31
32#include <initializer_list>
33#include <iterator>
34#include <memory>
35
36namespace std
37{
38 /**
39 * 23.3.6, vector:
40 */
41
42 template<class T, class Allocator = allocator<T>>
43 class vector
44 {
45 public:
46 using value_type = T;
47 using reference = value_type&;
48 using const_reference = const value_type&;
49 using allocator_type = Allocator;
50 using size_type = size_t;
51 using difference_type = ptrdiff_t;
52 using pointer = typename allocator_traits<Allocator>::pointer;
53 using const_pointer = typename allocator_traits<Allocator>::pointer;
54 using iterator = pointer;
55 using const_iterator = const_pointer;
56 using reverse_iterator = std::reverse_iterator<iterator>;
57 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
58
59 vector() noexcept
60 : vector{Allocator{}}
61 { /* DUMMY BODY */ }
62
63 explicit vector(const Allocator&);
64
65 explicit vector(size_type n, const Allocator& alloc = Allocator{});
66
67 vector(size_type n, const T& val, const Allocator& alloc = Allocator{});
68
69 template<class InputIterator>
70 vector(InputIterator first, InputIterator last,
71 const Allocator& alloc = Allocator{});
72
73 vector(const vector& other);
74
75 vector(vector&& other) noexcept;
76
77 vector(const vector& other, const Allocator& alloc);
78
79 vector(initializer_list<T> init, const Allocator& alloc = Allocator{});
80
81 ~vector();
82
83 vector& operator=(const vector& other);
84
85 vector& operator=(vector&& other)
86 noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
87 allocator_traits<Allocator>::is_always_equal::value)
88 {
89 return *this;
90 }
91
92 vector& operator=(initializer_list<T> init);
93
94 template<class InputIterator>
95 void assign(InputIterator first, InputIterator last);
96
97 void assign(size_type n, const T& val);
98
99 void assign(initializer_list<T> init);
100
101 allocator_type get_allocator() const noexcept;
102 };
103}
104
105#endif
Note: See TracBrowser for help on using the repository browser.