1 // Copyright (C) 2021 T. Zachary Laine
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_STL_INTERFACES_USE_CONCEPTS
8 void compile_seq_cont_constrained_pop_back() {}
12 #include <initializer_list>
14 #include <type_traits>
18 #include <boost/stl_interfaces/sequence_container_interface.hpp>
21 struct container
: boost::stl_interfaces::sequence_container_interface
<
23 boost::stl_interfaces::element_layout::contiguous
>
26 using super
= boost::stl_interfaces::sequence_container_interface
<
28 boost::stl_interfaces::element_layout::contiguous
>;
29 using container_type
= std::vector
<T
>;
31 using value_type
= typename
container_type::value_type
;
32 using reference
= typename
container_type::reference
;
33 using const_reference
= typename
container_type::const_reference
;
34 using iterator
= typename
container_type::iterator
;
35 using const_iterator
= typename
container_type::const_iterator
;
36 using difference_type
= typename
container_type::difference_type
;
37 using size_type
= typename
container_type::size_type
;
39 container() = default;
40 container(const container
&) = default;
41 container(container
&&) = default;
42 ~container() = default;
43 container
& operator=(const container
&) = default;
44 container
& operator=(container
&&) = default;
46 container(size_type count
, const_reference value
) : c(count
, value
) {}
47 container(std::initializer_list
<value_type
> init
) : c(init
) {}
49 template<class InputIt
>
50 container(InputIt first
, InputIt last
) : c(first
, last
)
53 iterator
begin() noexcept
{ return c
.begin(); }
54 iterator
end() noexcept
{ return c
.end(); }
56 size_type
max_size() const noexcept
{ return c
.max_size(); }
58 template<class InputIt
>
59 iterator
insert(const_iterator pos
, InputIt first
, InputIt last
)
61 return c
.insert(pos
, first
, last
);
64 template<class... Args
>
65 iterator
emplace(const_iterator pos
, Args
&&... args
)
67 return c
.emplace(pos
, std::forward
<Args
>(args
)...);
70 iterator
erase(const_iterator first
, const_iterator last
)
72 return c
.erase(first
, last
);
75 template<class... Args
>
76 requires(std::constructible_from
<value_type
, Args
&&...>) reference
77 emplace_back(Args
&&... args
)
79 return c
.emplace_back(std::forward
<Args
>(args
)...);
82 void swap(container
& other
) { c
.swap(other
.c
); }
93 void compile_seq_cont_constrained_pop_back()
106 std::vector
<std::unique_ptr
<int>> v
;
107 v
.emplace_back(new int);
110 container
<std::unique_ptr
<int>> c
;
111 c
.emplace_back(new int);