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

P0843 inplace_vector (draft) #4848

Closed
wants to merge 1 commit into from

Conversation

vasama
Copy link
Contributor

@vasama vasama commented Jul 20, 2024

  • Added <inplace_vector> according to P0843
  • Copied the constexpr vector unit test with some changes.
  • The constexpr tests don't yet work due to the use of public uninitialized_* functions from <memory>.
    The _Uninitialized_* from <xmemory> require an allocator parameter which we don't have here.
    Should we
    • fake the allocator and use those functions, or
    • add non-allocator aware versions of those functions, or
    • do something else entirely?
  • Left TODO comments in the code for open questions:
    • The aforementioned <memory> functions usage.
    • _Inplace_vector_nontrivial_dummy_type is a duplicate of _Nontrivial_dummy_type in <optional>.
    • _Inplace_vector_value_init_tag is a duplicate of _Value_init_tag in <vector>.
  • I noticed that vector::pop_back checks for _ITERATOR_DEBUG_LEVEL and not _CONTAINER_DEBUG_LEVEL. I followed suit, but is that intended?

I'm aware that you're prioritising C++23 features for now. This PR will just be waiting in the meantime.

@vasama
Copy link
Contributor Author

vasama commented Jul 20, 2024

@microsoft-github-policy-service agree

Copy link
Contributor

@frederick-vs-ja frederick-vs-ja left a comment

Choose a reason for hiding this comment

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

Thank you!

I think I can answer these questions.

Once MSVC STL start to accept PR for C++26 features, <yvals_core.h> and corresponding feature test macro test file should also be updated.

#if _STL_COMPILER_PREPROCESSOR
#include <xmemory>

#include <memory> // TODO: Required for uninitialized range ops without allocator parameter
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't want constexpr to be blocked, perhaps we should add _Uglified constexpr versions of these standard algorithms in <xmemory> and add // TRANSITION, P2283 comments. This will allow us to include <xmemory> only.

But I think the used algorithms should be moved to <xmemory> eventually.

stl/inc/inplace_vector Outdated Show resolved Hide resolved
stl/inc/inplace_vector Outdated Show resolved Hide resolved
stl/inc/inplace_vector Outdated Show resolved Hide resolved
stl/inc/inplace_vector Outdated Show resolved Hide resolved
stl/inc/inplace_vector Outdated Show resolved Hide resolved
Comment on lines 80 to 117
_NODISCARD constexpr bool operator==(const _Inplace_vector_const_iterator& _Right) const noexcept {
return _Ptr == _Right._Ptr;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably buggy, see #4847. How about changing iterator types to _Inplace_vector_iterator::_Iterator<_IsConst> and provide comparison operators as hidden friends?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

inplace_vector<expected<any, char>, 1> cont{};
(void) (cont.begin() == cont.end());

This works. Is that good enough?

stl/inc/inplace_vector Outdated Show resolved Hide resolved
stl/inc/inplace_vector Outdated Show resolved Hide resolved
@StephanTLavavej
Copy link
Member

I appreciate the enthusiasm, but in #4766 we clearly explained:

Note: We're focused on implementing the remaining library-only features in C++23. Until that's done, we will NOT be accepting PRs for C++26 features.

It's going to be a while before we can accept C++26 PRs. I think it'll be distracting and unproductive (as merge conflicts accumulate) to keep a PR open for what's likely to be more than a year, so I'm going to go ahead and close this. You're welcome to resubmit a PR when we begin work on C++26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants