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

Lower lowest supported version to C++17. #22

Merged
merged 6 commits into from
Nov 19, 2024
Merged

Conversation

wusatosi
Copy link
Member

This PR disables ranges and concept based on feature testing flags.
Swaps out C++ 20 specific functions with alternatives.

@wusatosi wusatosi marked this pull request as ready for review November 18, 2024 17:22
Comment on lines 549 to 577
auto final = std::construct_at(end(), std::forward<Args>(args)...);
// TODO: what is the feature flag for std::construct_at ??
// auto final = std::construct_at(end(), std::forward<Args>(args)...);
// This is just construct_at expanded out.
auto final = ::new (end()) T(std::forward<Args>(args)...);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I selectively use construct_at instead of placement new?

construct_at doesn't have a feature-test macro.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DeveloperPaul123 do you know how to approach this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it could be __cpp_lib_constexpr_dynamic_alloc or __cpp_constexpr_dynamic_alloc as construct_at was added in P0784R7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 thanks!

I will add a patch later.

I have a question for this, is there a constexpr construct_at for C++17? Placement new doesn't seem to be constexpr friendly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem!

And no... at least not that I'm aware of off the top of my head. I would have to do some digging to find out.

Copy link
Member Author

@wusatosi wusatosi Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright I guess constexpr stays at C++20 then.

Copy link
Member

@DeveloperPaul123 DeveloperPaul123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, nice work! If we can resolve the construct_at difficulties I think this is good to merge.

@wusatosi
Copy link
Member Author

@@ -259,15 +272,22 @@ class inplace_vector : public inplace_vector_base<T, Capacity> {
base::uninitialized_copy(first, last, this->begin());
}
}
#ifdef __cpp_lib_containers_ranges
#else
template <class Itr> constexpr inplace_vector(Itr first, Itr last) : base() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worth constraining Itr here using old school SFINAE?

Copy link
Member Author

@wusatosi wusatosi Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Egh! I do hate writing enable_if and template magics.

I think we should leave this as is, we can come back and write constraints as cherry-on-top.

There's other things (tests and constexpr) I want to focus on.

auto final = std::construct_at(end(), std::forward<Args>(args)...);
#else
// Note placement new may not be not constexpr friendly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Note placement new may not be not constexpr friendly
// Note: placement new may not be non-constexpr friendly

I think this is what was intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops typo here, placement new is not constexpr friendly. Thanks for double checking 😅

Copy link
Member

@DeveloperPaul123 DeveloperPaul123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple comments, but otherwise looks good to me. I tested it locally on Linux with GCC 12 and Clang 18

@wusatosi wusatosi merged commit 9573915 into bemanproject:main Nov 19, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants