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

Add allocator::rebind for c++20 #3

Merged
merged 2 commits into from
Sep 11, 2021

Conversation

SilverTuxedo
Copy link
Contributor

The rebind member has been removed from std::allocator in c++20 following
its deprecation in c++17. However, since the jxy allocator cannot be constructed
like the default allocator due to its custom template parameters, it must define
this member.

Fixes #2

The `rebind` member has been removed from std::allocator in c++20 following
its deprecation in c++17. However, since the jxy allocator cannot be constructed
like the default allocator due to its custom template parameters, it must define
this member.
@@ -89,6 +89,12 @@ class allocator
return memory;
}

template <typename Other>
struct rebind
Copy link
Owner

Choose a reason for hiding this comment

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

rebind was deprecated in cpp17 and removed in cpp20 I'm a little weary to accept this change because of this, allow me some time to investigate

Copy link
Owner

Choose a reason for hiding this comment

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

Okay, so I did a little digging and while rebind is deprecated on std::allocator it may be still required for this custom allocator:

https://en.cppreference.com/w/cpp/named_req/Allocator#cite_note-2

↑ rebind is only optional (provided by std::allocator_traits) if this allocator is a template of the form SomeAllocator<T, Args>, where Args is zero or more additional template type parameters.

That said, I'm a little perplexed why std::_Replace_first_parameter<_Other,_Ty> is tripping over this:

3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xmemory(469,66): error C2027: use of undefined type 'std::_Replace_first_parameter<_Other,_Ty>'
3>        with
3>        [
3>            _Other=int,
3>            _Ty=jxy::details::allocator<int,PagedPool,809976148>
3>        ]

Let's at least comment/document the reason for this change so when someone goes to look at this later they understand why jxy::allocator has rebind functionality that doesn't mirror std::allocator deprecating it.

@jxy-s jxy-s merged commit cd91f7b into jxy-s:main Sep 11, 2021
@SilverTuxedo SilverTuxedo deleted the bugfix/cpp20-rebind branch September 12, 2021 08:02
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.

Add support for C++20
2 participants