Skip to content

Commit 68b2703

Browse files
committed
lazy_push_front and push_front no longer have unnecessary forward_linked_list and bidirectional_linked_list dependencies.
1 parent 2088c78 commit 68b2703

File tree

5 files changed

+82
-56
lines changed

5 files changed

+82
-56
lines changed

source/containers/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,12 @@ target_sources(containers_test PRIVATE
255255
test/insert.cpp
256256
test/lazy_push_back.cpp
257257
test/lazy_push_back_into_capacity.cpp
258+
test/lazy_push_front.cpp
258259
test/linear_map.cpp
259260
test/pop_back.cpp
260261
test/push_back.cpp
261262
test/push_back_into_capacity.cpp
263+
test/push_front.cpp
262264
test/range_view.cpp
263265
test/shrink_to_fit.cpp
264266
test/stable_vector.cpp

source/containers/lazy_push_front.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,19 @@
55

66
module;
77

8-
#include <bounded/assert.hpp>
9-
108
#include <operators/forward.hpp>
119

1210
export module containers.lazy_push_front;
1311

1412
import containers.algorithms.splice;
1513
import containers.begin_end;
16-
import containers.bidirectional_linked_list;
17-
import containers.forward_linked_list;
1814
import containers.front;
1915
import containers.lazy_push_back;
2016
import containers.range_value_t;
2117
import containers.splicable;
2218
import containers.supports_lazy_insert_after;
2319

2420
import bounded;
25-
import bounded.test_int;
26-
import std_module;
2721

2822
namespace containers {
2923

@@ -49,27 +43,3 @@ constexpr auto lazy_push_front(
4943
}
5044

5145
} // namespace containers
52-
53-
using namespace bounded::literal;
54-
55-
template<typename Container>
56-
constexpr auto test_lazy_push_front() -> bool {
57-
auto c = Container();
58-
59-
containers::lazy_push_front(c, bounded::value_to_function(3));
60-
BOUNDED_ASSERT(c == Container({3}));
61-
62-
containers::lazy_push_front(c, bounded::value_to_function(4));
63-
BOUNDED_ASSERT(c == Container({4, 3}));
64-
65-
containers::lazy_push_front(c, bounded::value_to_function(5));
66-
BOUNDED_ASSERT(c == Container({5, 4, 3}));
67-
68-
containers::lazy_push_front(c, bounded::value_to_function(12));
69-
BOUNDED_ASSERT(c == Container({12, 5, 4, 3}));
70-
71-
return true;
72-
}
73-
74-
static_assert(test_lazy_push_front<containers::bidirectional_linked_list<bounded_test::non_copyable_integer>>());
75-
static_assert(test_lazy_push_front<containers::forward_linked_list<bounded_test::non_copyable_integer>>());

source/containers/push_front.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@
33
// (See accompanying file LICENSE_1_0.txt or copy at
44
// http://www.boost.org/LICENSE_1_0.txt)
55

6-
module;
7-
8-
#include <bounded/assert.hpp>
9-
106
export module containers.push_front;
117

12-
import containers.bidirectional_linked_list;
13-
import containers.forward_linked_list;
148
import containers.front;
159
import containers.lazy_push_front;
1610
import containers.range_value_t;
1711

1812
import bounded;
19-
import bounded.test_int;
2013
import std_module;
2114

2215
namespace containers {
@@ -55,22 +48,3 @@ constexpr auto push_front(Container & container, range_value_t<Container> && val
5548
}
5649

5750
} // namespace containers
58-
59-
template<typename Container>
60-
constexpr auto test_push_front() -> bool {
61-
// TODO: Why is this line necessary?
62-
static_assert(containers::lazy_push_frontable<Container>);
63-
auto v = Container();
64-
containers::push_front(v, 0);
65-
BOUNDED_ASSERT(v == Container({0}));
66-
containers::push_front(v, 1);
67-
BOUNDED_ASSERT(v == Container({1, 0}));
68-
containers::push_front(v, 2);
69-
BOUNDED_ASSERT(v == Container({2, 1, 0}));
70-
containers::push_front(v, 3);
71-
BOUNDED_ASSERT(v == Container({3, 2, 1, 0}));
72-
return true;
73-
}
74-
75-
static_assert(test_push_front<containers::bidirectional_linked_list<bounded_test::non_copyable_integer>>());
76-
static_assert(test_push_front<containers::forward_linked_list<bounded_test::non_copyable_integer>>());
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright David Stone 2022.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
module;
7+
8+
#include <bounded/assert.hpp>
9+
10+
export module containers.test.lazy_push_front;
11+
12+
import containers.bidirectional_linked_list;
13+
import containers.forward_linked_list;
14+
import containers.lazy_push_front;
15+
16+
import bounded;
17+
import bounded.test_int;
18+
19+
using namespace bounded::literal;
20+
21+
template<typename Container>
22+
constexpr auto test_lazy_push_front() -> bool {
23+
auto c = Container();
24+
25+
containers::lazy_push_front(c, bounded::value_to_function(3));
26+
BOUNDED_ASSERT(c == Container({3}));
27+
28+
containers::lazy_push_front(c, bounded::value_to_function(4));
29+
BOUNDED_ASSERT(c == Container({4, 3}));
30+
31+
containers::lazy_push_front(c, bounded::value_to_function(5));
32+
BOUNDED_ASSERT(c == Container({5, 4, 3}));
33+
34+
containers::lazy_push_front(c, bounded::value_to_function(12));
35+
BOUNDED_ASSERT(c == Container({12, 5, 4, 3}));
36+
37+
return true;
38+
}
39+
40+
static_assert(test_lazy_push_front<containers::bidirectional_linked_list<bounded_test::non_copyable_integer>>());
41+
static_assert(test_lazy_push_front<containers::forward_linked_list<bounded_test::non_copyable_integer>>());
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright David Stone 2022.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
module;
7+
8+
#include <bounded/assert.hpp>
9+
10+
export module containers.test.push_front;
11+
12+
import containers.push_front;
13+
14+
import containers.bidirectional_linked_list;
15+
import containers.forward_linked_list;
16+
import containers.front;
17+
import containers.lazy_push_front;
18+
import containers.range_value_t;
19+
20+
import bounded;
21+
import bounded.test_int;
22+
import std_module;
23+
24+
template<typename Container>
25+
constexpr auto test_push_front() -> bool {
26+
auto v = Container();
27+
containers::push_front(v, 0);
28+
BOUNDED_ASSERT(v == Container({0}));
29+
containers::push_front(v, 1);
30+
BOUNDED_ASSERT(v == Container({1, 0}));
31+
containers::push_front(v, 2);
32+
BOUNDED_ASSERT(v == Container({2, 1, 0}));
33+
containers::push_front(v, 3);
34+
BOUNDED_ASSERT(v == Container({3, 2, 1, 0}));
35+
return true;
36+
}
37+
38+
static_assert(test_push_front<containers::bidirectional_linked_list<bounded_test::non_copyable_integer>>());
39+
static_assert(test_push_front<containers::forward_linked_list<bounded_test::non_copyable_integer>>());

0 commit comments

Comments
 (0)