Skip to content
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

[libc++][test] Avoid using allocator<const T> #73545

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#ifndef TEST_STD_CONTAINERS_VIEWS_MDSPAN_MINIMAL_ELEMENT_TYPE_H
#define TEST_STD_CONTAINERS_VIEWS_MDSPAN_MINIMAL_ELEMENT_TYPE_H

#include<memory>
#include <memory>
#include <type_traits>

// Idiosyncratic element type for mdspan
// Make sure we don't assume copyable, default constructible, movable etc.
Expand All @@ -25,7 +26,7 @@ struct MinimalElementType {
template<class T, size_t N>
struct ElementPool {
constexpr ElementPool() {
ptr_ = std::allocator<T>().allocate(N);
ptr_ = std::allocator<std::remove_const_t<T>>().allocate(N);
for (int i = 0; i != N; ++i)
std::construct_at(ptr_ + i, 42);
}
Expand All @@ -35,11 +36,11 @@ struct ElementPool {
constexpr ~ElementPool() {
for (int i = 0; i != N; ++i)
std::destroy_at(ptr_ + i);
std::allocator<T>().deallocate(ptr_, N);
std::allocator<std::remove_const_t<T>>().deallocate(ptr_, N);
}

private:
T* ptr_;
std::remove_const_t<T>* ptr_;
};

#endif // TEST_STD_CONTAINERS_VIEWS_MDSPAN_MINIMAL_ELEMENT_TYPE_H
Loading