Skip to content

Commit 0511601

Browse files
committed
Rename namespace for consistency
1 parent b81a3c7 commit 0511601

File tree

11 files changed

+82
-86
lines changed

11 files changed

+82
-86
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Contributions are welcome.
4949

5050
#include <beman/inplace_vector/inplace_vector.hpp>
5151

52-
using namespace beman;
52+
using namespace beman::inplace_vector;
5353

5454
/**
5555
* Generates fibonacci sequence using inplace_vector.
@@ -93,21 +93,21 @@ Note this is not part of the standard Library and should not be relied on once
9393
`constexpr` requirement stabilize.
9494
9595
Example Usage:
96-
`static_assert(beman::has_constexpr_support<beman::inplace_vector<int, 5>>)`.
96+
`static_assert(beman::has_constexpr_support<beman::inplace_vector::inplace_vector<int, 5>>)`.
9797
9898
### Freestanding
9999
100-
`beman::freestanding::inplace_vector` implements a minimal freestanding version of the specification,
100+
`beman::inplace_vector::freestanding::inplace_vector` implements a minimal freestanding version of the specification,
101101
which marks all potentially throwing functions as `= deleted`.
102102
This is useful for platforms without exception support, as it will generate a compile-time error
103103
instead of a potential runtime error when trying to use a throwing function.
104104
105105
``` C++
106-
beman::inplace_vector<int, 1> iv;
106+
beman::inplace_vector::inplace_vector<int, 1> iv;
107107
iv.resize(0); // OK
108108
iv.resize(10); // will throw or abort
109109
110-
beman::freestanding::inplace_vector<int, 1> fs_iv;
110+
beman::inplace_vector::freestanding::inplace_vector<int, 1> fs_iv;
111111
fs_iv.resize(0); // will generate a compile-time error
112112
fs_iv.resize(10); // will generate a compile-time error
113113
```

examples/fibonacci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <beman/inplace_vector/inplace_vector.hpp>
66

7-
using namespace beman;
7+
using namespace beman::inplace_vector;
88

99
/**
1010
* Generates fibonacci sequence using inplace_vector.

include/beman/inplace_vector/inplace_vector.hpp

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ inline constexpr from_range_t from_range;
4444
}; // namespace beman
4545

4646
// Private utilities
47-
namespace beman::details::inplace_vector {
47+
namespace beman::inplace_vector::details {
4848

4949
// clang-format off
5050
// Smallest unsigned integer that can represent values in [0, N].
@@ -80,10 +80,7 @@ concept lessthan_comparable = requires(const T &a, const T &b) {
8080
{ a < b } -> std::convertible_to<bool>;
8181
};
8282

83-
} // namespace beman::details::inplace_vector
84-
8583
// Types implementing the `inplace_vector`'s storage
86-
namespace beman::details::inplace_vector {
8784
namespace storage {
8885

8986
// Storage for zero elements.
@@ -271,22 +268,20 @@ struct inplace_vector_base : private storage::storage_for<T, N> {
271268
// element access
272269

273270
constexpr reference operator[](size_type n) {
274-
return details::inplace_vector::index(*this, n);
271+
return details::index(*this, n);
275272
}
276273
constexpr const_reference operator[](size_type n) const {
277-
return details::inplace_vector::index(*this, n);
278-
}
279-
constexpr reference front() {
280-
return details::inplace_vector::index(*this, size_type(0));
274+
return details::index(*this, n);
281275
}
276+
constexpr reference front() { return details::index(*this, size_type(0)); }
282277
constexpr const_reference front() const {
283-
return details::inplace_vector::index(*this, size_type(0));
278+
return details::index(*this, size_type(0));
284279
}
285280
constexpr reference back() {
286-
return details::inplace_vector::index(*this, size() - size_type(1));
281+
return details::index(*this, size() - size_type(1));
287282
}
288283
constexpr const_reference back() const {
289-
return details::inplace_vector::index(*this, size() - size_type(1));
284+
return details::index(*this, size() - size_type(1));
290285
}
291286

292287
// [containers.sequences.inplace_vector.data], data access
@@ -361,7 +356,7 @@ struct inplace_vector_base : private storage::storage_for<T, N> {
361356
return unchecked_emplace_back(std::forward<T &&>(x));
362357
}
363358

364-
template <details::inplace_vector::container_compatible_range<T> R>
359+
template <details::container_compatible_range<T> R>
365360
constexpr std::ranges::borrowed_iterator_t<R> try_append_range(R &&rg)
366361
requires(std::constructible_from<T, std::ranges::range_reference_t<R>>)
367362
{
@@ -428,7 +423,7 @@ struct inplace_vector_base : private storage::storage_for<T, N> {
428423

429424
constexpr friend auto operator<=>(const inplace_vector_base &x,
430425
const inplace_vector_base &y)
431-
requires(beman::details::inplace_vector::lessthan_comparable<T>)
426+
requires(details::lessthan_comparable<T>)
432427
{
433428
if constexpr (std::three_way_comparable<T>) {
434429
return std::lexicographical_compare_three_way(x.begin(), x.end(),
@@ -514,19 +509,17 @@ struct inplace_vector_base : private storage::storage_for<T, N> {
514509
}
515510
};
516511

517-
} // namespace beman::details::inplace_vector
512+
} // namespace beman::inplace_vector::details
518513

519-
namespace beman {
514+
namespace beman::inplace_vector {
520515

521516
template <typename IV>
522517
concept has_constexpr_support =
523-
details::inplace_vector::satify_constexpr<typename IV::value_type,
524-
IV::capacity()>;
518+
details::satify_constexpr<typename IV::value_type, IV::capacity()>;
525519

526520
/// Dynamically-resizable fixed-N vector with inplace storage.
527521
template <class T, size_t N>
528-
struct inplace_vector
529-
: public details::inplace_vector::inplace_vector_base<T, N> {
522+
struct inplace_vector : public details::inplace_vector_base<T, N> {
530523
using value_type = T;
531524
using pointer = T *;
532525
using const_pointer = const T *;
@@ -563,7 +556,7 @@ struct inplace_vector
563556
return this->back();
564557
}
565558

566-
template <details::inplace_vector::container_compatible_range<T> R>
559+
template <details::container_compatible_range<T> R>
567560
constexpr void append_range(R &&rg)
568561
requires(std::constructible_from<T, std::ranges::range_reference_t<R>>)
569562
{
@@ -614,7 +607,7 @@ struct inplace_vector
614607
return pos;
615608
}
616609

617-
template <details::inplace_vector::container_compatible_range<T> R>
610+
template <details::container_compatible_range<T> R>
618611
constexpr iterator insert_range(const_iterator position, R &&rg)
619612
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
620613
std::movable<T>)
@@ -672,7 +665,7 @@ struct inplace_vector
672665
this->clear();
673666
insert(this->begin(), first, last);
674667
}
675-
template <details::inplace_vector::container_compatible_range<T> R>
668+
template <details::container_compatible_range<T> R>
676669
constexpr void assign_range(R &&rg)
677670
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
678671
std::movable<T>)
@@ -738,13 +731,13 @@ struct inplace_vector
738731
if (pos >= this->size()) [[unlikely]] {
739732
BEMAN_IV_THROW_OR_ABORT(std::out_of_range("inplace_vector::at"));
740733
}
741-
return details::inplace_vector::index(*this, pos);
734+
return details::index(*this, pos);
742735
}
743736
constexpr const_reference at(size_type pos) const {
744737
if (pos >= this->size()) [[unlikely]] {
745738
BEMAN_IV_THROW_OR_ABORT(std::out_of_range("inplace_vector::at"));
746739
}
747-
return details::inplace_vector::index(*this, pos);
740+
return details::index(*this, pos);
748741
}
749742

750743
// [containers.sequences.inplace_vector.cons], construct/copy/destroy
@@ -780,7 +773,7 @@ struct inplace_vector
780773
insert(this->begin(), first, last);
781774
}
782775

783-
template <details::inplace_vector::container_compatible_range<T> R>
776+
template <details::container_compatible_range<T> R>
784777
constexpr inplace_vector(beman::from_range_t, R &&rg)
785778
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
786779
std::movable<T>)
@@ -791,8 +784,7 @@ struct inplace_vector
791784

792785
namespace freestanding {
793786
template <class T, size_t N>
794-
struct inplace_vector
795-
: public details::inplace_vector::inplace_vector_base<T, N> {
787+
struct inplace_vector : public details::inplace_vector_base<T, N> {
796788
using value_type = T;
797789
using pointer = T *;
798790
using const_pointer = const T *;
@@ -818,7 +810,7 @@ struct inplace_vector
818810
requires(std::constructible_from<T, T &&>)
819811
= delete;
820812

821-
template <details::inplace_vector::container_compatible_range<T> R>
813+
template <details::container_compatible_range<T> R>
822814
constexpr void append_range(R &&rg)
823815
requires(std::constructible_from<T, std::ranges::range_reference_t<R>>)
824816
= delete;
@@ -835,7 +827,7 @@ struct inplace_vector
835827
std::movable<T>)
836828
= delete;
837829

838-
template <details::inplace_vector::container_compatible_range<T> R>
830+
template <details::container_compatible_range<T> R>
839831
constexpr iterator insert_range(const_iterator position, R &&rg)
840832
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
841833
std::movable<T>)
@@ -871,7 +863,7 @@ struct inplace_vector
871863
requires(std::constructible_from<T, std::iter_reference_t<InputIterator>> &&
872864
std::movable<T>)
873865
= delete;
874-
template <details::inplace_vector::container_compatible_range<T> R>
866+
template <details::container_compatible_range<T> R>
875867
constexpr void assign_range(R &&rg)
876868
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
877869
std::movable<T>)
@@ -925,7 +917,7 @@ struct inplace_vector
925917
std::movable<T>)
926918
= delete;
927919

928-
template <details::inplace_vector::container_compatible_range<T> R>
920+
template <details::container_compatible_range<T> R>
929921
constexpr inplace_vector(beman::from_range_t, R &&rg)
930922
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
931923
std::movable<T>)
@@ -935,25 +927,24 @@ struct inplace_vector
935927
} // namespace freestanding
936928

937929
template <typename T, std::size_t N, typename U = T>
938-
constexpr std::size_t
939-
erase(details::inplace_vector::inplace_vector_base<T, N> &c, const U &value) {
930+
constexpr std::size_t erase(details::inplace_vector_base<T, N> &c,
931+
const U &value) {
940932
auto it = std::remove(c.begin(), c.end(), value);
941933
auto r = std::distance(it, c.end());
942934
c.erase(it, c.end());
943935
return r;
944936
}
945937

946938
template <typename T, std::size_t N, typename Predicate>
947-
constexpr std::size_t
948-
erase_if(details::inplace_vector::inplace_vector_base<T, N> &c,
949-
Predicate pred) {
939+
constexpr std::size_t erase_if(details::inplace_vector_base<T, N> &c,
940+
Predicate pred) {
950941
auto it = std::remove_if(c.begin(), c.end(), pred);
951942
auto r = std::distance(it, c.end());
952943
c.erase(it, c.end());
953944
return r;
954945
}
955946

956-
} // namespace beman
947+
} // namespace beman::inplace_vector
957948

958949
#undef IV_EXPECT
959950

tests/beman/inplace_vector/compare.test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <cmath>
55
#include <compare>
66

7-
using namespace beman;
7+
using namespace beman::inplace_vector;
88

99
template <class T>
1010
concept has_threeway = requires(const T &t) {
@@ -13,7 +13,7 @@ concept has_threeway = requires(const T &t) {
1313

1414
template <class T>
1515
concept lessthan_comparable =
16-
beman::details::inplace_vector::lessthan_comparable<T>;
16+
beman::inplace_vector::details::lessthan_comparable<T>;
1717

1818
template <typename T> struct vec_list {
1919
T empty;

tests/beman/inplace_vector/constexpr.test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ struct Some {
3131
};
3232
static_assert(std::is_trivial_v<Some>);
3333

34-
using beman::has_constexpr_support;
35-
using beman::inplace_vector;
34+
using beman::inplace_vector::has_constexpr_support;
35+
using beman::inplace_vector::inplace_vector;
3636

3737
static_assert(has_constexpr_support<inplace_vector<int, 50>>);
3838
static_assert(has_constexpr_support<inplace_vector<Some, 50>>);
@@ -45,8 +45,8 @@ static_assert(!has_constexpr_support<inplace_vector<std::unique_ptr<int>, 50>>);
4545

4646
#define TEST(NAME) \
4747
static_assert(std::invoke([]() { \
48-
NAME<beman::inplace_vector<int, 20>>(); \
49-
NAME<beman::inplace_vector<Some, 20>>(); \
48+
NAME<beman::inplace_vector::inplace_vector<int, 20>>(); \
49+
NAME<beman::inplace_vector::inplace_vector<Some, 20>>(); \
5050
return true; \
5151
}), \
5252
"##NAME");
@@ -269,8 +269,8 @@ TEST(test_op_comp);
269269

270270
template <typename IV> constexpr void test_erase() {
271271
IV v{0, 1, 2, 3, 3, 5};
272-
(void)beman::erase(v, 3);
273-
(void)beman::erase_if(v, [](auto v) { return v < 3; });
272+
(void)beman::inplace_vector::erase(v, 3);
273+
(void)beman::inplace_vector::erase_if(v, [](auto v) { return v < 3; });
274274
}
275275
TEST(test_erase)
276276

@@ -298,7 +298,7 @@ static_assert(!has_constexpr_support<inplace_vector<Complex, 50>>);
298298

299299
template <typename T> constexpr void speical_test_empty() {
300300
static_assert(!std::is_trivially_default_constructible_v<T>);
301-
using IV = beman::inplace_vector<T, 0>;
301+
using IV = beman::inplace_vector::inplace_vector<T, 0>;
302302

303303
std::array<T, 10> arr;
304304
arr.fill(T{50});

tests/beman/inplace_vector/constructors.test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ TYPED_TEST(Constructors, CopyRanges) {
137137
TYPED_TEST(Constructors, freestandingConversion) {
138138
using T = TestFixture::T;
139139

140-
using IV = beman::inplace_vector<T, 5>;
141-
using FS = beman::freestanding::inplace_vector<T, 5>;
140+
using IV = beman::inplace_vector::inplace_vector<T, 5>;
141+
using FS = beman::inplace_vector::freestanding::inplace_vector<T, 5>;
142142

143143
static_assert(std::is_constructible_v<FS, FS>);
144144
static_assert(std::is_constructible_v<IV, IV>);

tests/beman/inplace_vector/erasure.test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TYPED_TEST(Erasure, ByValue) {
3535
device.push_back(duplicates);
3636
}
3737

38-
beman::erase(device, duplicates);
38+
beman::inplace_vector::erase(device, duplicates);
3939
EXPECT_EQ(uniques, device);
4040
}
4141

@@ -59,8 +59,8 @@ TYPED_TEST(Erasure, ByPred) {
5959
for (auto i = 0; i < static_cast<int>(device.capacity()); ++i)
6060
device.push_back(T{i});
6161

62-
beman::erase_if(device,
63-
[&](auto &v) { return v.value > (device.capacity() / 2); });
62+
beman::inplace_vector::erase_if(
63+
device, [&](auto &v) { return v.value > (device.capacity() / 2); });
6464
EXPECT_TRUE(std::all_of(device.begin(), device.end(), [&](auto val) {
6565
return val.value <= (device.capacity() / 2);
6666
}));

tests/beman/inplace_vector/freestanding.test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ concept has_insert_initializer =
137137

138138
TEST(Freestanding, deleted) {
139139

140-
using IV = beman::inplace_vector<int, 10>;
141-
using FIV = beman::freestanding::inplace_vector<int, 10>;
140+
using IV = beman::inplace_vector::inplace_vector<int, 10>;
141+
using FIV = beman::inplace_vector::freestanding::inplace_vector<int, 10>;
142142

143143
using range = std::array<int, 10>;
144144
using input_iterator = std::istream_iterator<int>;
@@ -256,7 +256,7 @@ TEST(Freestanding, deleted) {
256256
}
257257

258258
TEST(Freestanding, usage) {
259-
using IV = beman::freestanding::inplace_vector<int, 10>;
259+
using IV = beman::inplace_vector::freestanding::inplace_vector<int, 10>;
260260
using T = IV::value_type;
261261

262262
IV device;

tests/beman/inplace_vector/gtest_setup.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ template <typename Param> class IVBasicTest : public ::testing::Test {
348348
public:
349349
using T = Param::value_type;
350350
inline static constexpr std::size_t N = Param::capacity;
351-
using X = beman::inplace_vector<T, N>;
351+
using X = beman::inplace_vector::inplace_vector<T, N>;
352352
using IV = X;
353353

354354
// Returns IV of size n with unique values

tests/beman/inplace_vector/inplace_vector.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <beman/inplace_vector/inplace_vector.hpp>
33
#include <cassert>
44

5-
using namespace beman;
5+
using namespace beman::inplace_vector;
66

77
template <typename T> constexpr void test() {
88
using vec = inplace_vector<T, 42>;

0 commit comments

Comments
 (0)