Skip to content

Commit

Permalink
Take FixedStack out of beta
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkaratarakis committed Aug 5, 2023
1 parent b693fcf commit d817000
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Header-only C++20 library that provides containers with the following properties
* `FixedVector` - Vector implementation with `std::vector` API and "fixed container" properties
* `FixedMap`/`FixedSet` - Red-Black Tree map/set implementation with `std::map`/`std::set` API and "fixed container" properties.
* `EnumMap`/`EnumSet` - For enum keys only, Map/Set implementation with `std::map`/`std::set` API and "fixed container" properties. O(1) lookups.
* `FixedStack` - Stack implementation with `std::stack` API and "fixed container" properties
* `StringLiteral` - Compile-time null-terminated literal string.
* Rich enums - `enum` & `class` hybrid.

Expand Down Expand Up @@ -136,6 +137,21 @@ More examples can be found [here](test/enums_test_common.hpp).
constexpr auto s4 = EnumSet<Color>::complement_of(s2); // empty set
```

- FixedStack
```C++
constexpr FixedStack<int, 3> s1 = []()
{
FixedStack<int, 3> v1{};
int my_int = 77;
v1.push(my_int);
v1.push(99);
return v1;
}();

static_assert(s1.top() == 99);
static_assert(s1.size() == 2);
```

- StringLiteral
```C++
static constexpr const char* s = "blah"; // strlen==4, sizeof==8
Expand Down
4 changes: 2 additions & 2 deletions include/fixed_containers/fixed_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <cstddef>

namespace fixed_containers::fixed_stack_detail
namespace fixed_containers
{
template <typename T, std::size_t MAXIMUM_SIZE>
class FixedStack
Expand Down Expand Up @@ -79,4 +79,4 @@ class FixedStack
}
};

} // namespace fixed_containers::fixed_stack_detail
} // namespace fixed_containers
4 changes: 2 additions & 2 deletions test/fixed_stack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <stack>

namespace fixed_containers::fixed_stack_detail
namespace fixed_containers
{
// std::stack would be preferable, but it is not always constexpr
// The spec has it as non-constexpr as of C++23, including construction.
Expand Down Expand Up @@ -133,4 +133,4 @@ TEST(FixedStack, Pop)
static_assert(s1.size() == 1);
}

} // namespace fixed_containers::fixed_stack_detail
} // namespace fixed_containers

0 comments on commit d817000

Please sign in to comment.