-
Notifications
You must be signed in to change notification settings - Fork 11
Changed pragma once to include guard, Added maybe_unused to unused params, Removed comment cruft #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed pragma once to include guard, Added maybe_unused to unused params, Removed comment cruft #75
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||
|
|
||||||
| #pragma once | ||||||
| #pragma GCC diagnostic ignored "-Wunused-parameter" | ||||||
| #ifndef BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP | ||||||
| #define BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP | ||||||
|
|
||||||
| #include <algorithm> // for rotate... | ||||||
| #include <array> | ||||||
|
|
@@ -77,7 +77,8 @@ template <class T> struct zero_sized { | |||||
| using size_type = uint8_t; | ||||||
| static constexpr T *storage_data() noexcept { return nullptr; } | ||||||
| static constexpr size_type storage_size() noexcept { return 0; } | ||||||
| static constexpr void unsafe_set_size(size_t new_size) noexcept { | ||||||
| static constexpr void | ||||||
| unsafe_set_size([[maybe_unused]] size_t new_size) noexcept { | ||||||
| IV_EXPECT(new_size == 0 && | ||||||
| "tried to change size of empty storage to non-zero value"); | ||||||
| } | ||||||
|
|
@@ -224,34 +225,6 @@ struct inplace_vector | |||||
|
|
||||||
| // [containers.sequences.inplace_vector.cons], construct/copy/destroy | ||||||
| constexpr inplace_vector() noexcept = default; | ||||||
| // constexpr explicit inplace_vector(size_type n); | ||||||
| // constexpr inplace_vector(size_type n, const T& value); | ||||||
| // template <class InputIterator> // BUGBUG: why not model input_iterator? | ||||||
| // constexpr inplace_vector(InputIterator first, InputIterator | ||||||
| // last); | ||||||
| // template <details::inplace_vector::container_compatible_range<T> R> | ||||||
| // constexpr inplace_vector(from_range_t, R&& rg); | ||||||
| // from base-class, trivial if is_trivially_copy_constructible_v<T>: | ||||||
| // constexpr inplace_vector(const inplace_vector&); | ||||||
| // from base-class, trivial if is_trivially_move_constructible_v<T> | ||||||
| // constexpr inplace_vector(inplace_vector&&) noexcept(N == 0 || | ||||||
| // std::is_nothrow_move_constructible_v<T>); | ||||||
| // constexpr inplace_vector(std::initializer_list<T> il); | ||||||
| // from base-class, trivial if is_trivially_destructible_v<T> | ||||||
| // constexpr ~inplace_vector(); | ||||||
| // from base-class, trivial if is_trivially_destructible_v<T> && | ||||||
| // is_trivially_copy_assignable_v<T> | ||||||
| // constexpr inplace_vector& operator=(const inplace_vector& other); | ||||||
| // from base-class, trivial if is_trivially_destructible_v<T> && | ||||||
| // is_trivially_copy_assignable_v<T> | ||||||
| // constexpr inplace_vector& operator=(inplace_vector&& other) | ||||||
| // noexcept(N == 0 || is_nothrow_move_assignable_v<T>); | ||||||
| // template <class InputIterator> // BUGBUG: why not model input_iterator | ||||||
| // constexpr void assign(InputIterator first, InputIterator last); | ||||||
| // template<details::inplace_vector::container_compatible_range<T> R> | ||||||
| // constexpr void assign_range(R&& rg); | ||||||
| // constexpr void assign(size_type n, const T& u); | ||||||
| // constexpr void assign(std::initializer_list<T> il); | ||||||
|
|
||||||
| // iterators | ||||||
| constexpr iterator begin() noexcept { return storage_data(); } | ||||||
|
|
@@ -320,45 +293,6 @@ struct inplace_vector | |||||
| constexpr T *data() noexcept { return storage_data(); } | ||||||
| constexpr const T *data() const noexcept { return storage_data(); } | ||||||
|
|
||||||
| // [containers.sequences.inplace_vector.modifiers], modifiers | ||||||
| // template <class... Args> | ||||||
| // constexpr T& emplace_back(Args&&... args); | ||||||
| // constexpr T& push_back(const T& x); | ||||||
| // constexpr T& push_back(T&& x); | ||||||
| // template<details::inplace_vector::container_compatible_range<T> R> | ||||||
| // constexpr void append_range(R&& rg); | ||||||
| // constexpr void pop_back(); | ||||||
|
|
||||||
| // template<class... Args> | ||||||
| // constexpr T* try_emplace_back(Args&&... args); | ||||||
| // constexpr T* try_push_back(const T& value); | ||||||
| // constexpr T* try_push_back(T&& value); | ||||||
|
|
||||||
| // template<class... Args> | ||||||
| // constexpr T& unchecked_emplace_back(Args&&... args); | ||||||
| // constexpr T& unchecked_push_back(const T& value); | ||||||
| // constexpr T& unchecked_push_back(T&& value); | ||||||
|
|
||||||
| // template <class... Args> | ||||||
| // constexpr iterator emplace(const_iterator position, Args&&... args); | ||||||
| // constexpr iterator insert(const_iterator position, const T& x); | ||||||
| // constexpr iterator insert(const_iterator position, T&& x); | ||||||
| // constexpr iterator insert(const_iterator position, size_type n, const | ||||||
| // T& x); | ||||||
| // template <class InputIterator> | ||||||
| // constexpr iterator insert(const_iterator position, InputIterator | ||||||
| // first, InputIterator last); | ||||||
| // template<details::inplace_vector::container_compatible_range<T> R> | ||||||
| // constexpr iterator insert_range(const_iterator position, R&& rg); | ||||||
| // constexpr iterator insert(const_iterator position, | ||||||
| // std::initializer_list<T> | ||||||
| // il); constexpr iterator erase(const_iterator position); constexpr | ||||||
| // iterator erase(const_iterator first, const_iterator last); constexpr | ||||||
| // void swap(inplace_vector& x) | ||||||
| // noexcept(N == 0 || (std::is_nothrow_swappable_v<T> && | ||||||
| // std::is_nothrow_move_constructible_v<T>)); | ||||||
| // constexpr void clear() noexcept; | ||||||
|
|
||||||
| constexpr friend bool operator==(const inplace_vector &x, | ||||||
| const inplace_vector &y) { | ||||||
| return x.size() == y.size() && std::ranges::equal(x, y); | ||||||
|
|
@@ -372,12 +306,14 @@ struct inplace_vector | |||||
| } | ||||||
|
|
||||||
| private: // Utilities | ||||||
| constexpr void assert_iterator_in_range(const_iterator it) noexcept { | ||||||
| constexpr void | ||||||
| assert_iterator_in_range([[maybe_unused]] const_iterator it) noexcept { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These functions are left over artifacts from the original reference implementation. iirc they're not used anywhere, |
||||||
| IV_EXPECT(begin() <= it && "iterator not in range"); | ||||||
| IV_EXPECT(it <= end() && "iterator not in range"); | ||||||
| } | ||||||
| constexpr void assert_valid_iterator_pair(const_iterator first, | ||||||
| const_iterator last) noexcept { | ||||||
| constexpr void | ||||||
| assert_valid_iterator_pair([[maybe_unused]] const_iterator first, | ||||||
| [[maybe_unused]] const_iterator last) noexcept { | ||||||
| IV_EXPECT(first <= last && "invalid iterator pair"); | ||||||
| } | ||||||
| constexpr void assert_iterator_pair_in_range(const_iterator first, | ||||||
|
|
@@ -799,3 +735,5 @@ constexpr std::size_t erase_if(inplace_vector<T, N> &c, Predicate pred) { | |||||
| } // namespace beman | ||||||
|
|
||||||
| #undef IV_EXPECT | ||||||
|
|
||||||
| #endif // BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP | ||||||
|
||||||
| #endif // BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP | |
| #endif // BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work?
This is assuming we remove all the assertion related artifact.