Skip to content

ranges::to#307

Open
CaseyCarter wants to merge 9 commits intomasterfrom
to
Open

ranges::to#307
CaseyCarter wants to merge 9 commits intomasterfrom
to

Conversation

@CaseyCarter
Copy link
Owner

Per P1206 and Kona LEWG discussion.

_Cont __c(static_cast<_Args&&>(__args)...);
auto const __size = size(__r);
using __capacity = decltype(__c.capacity());
// if (__can_represent<__capacity>(__size)) ?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Incomplete thought?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, this is a potential means of dealing with "What happens if the container's capacity type cannot represent the range's size?" (which is what the comment should really say).

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is now tagged FIXME, and needs to be fixed before merging.


template<class _IRange, class _Cont>
requires __class_convertible<_Cont, _IRange>
constexpr auto operator|(_IRange&& __r, __class_closure<_Cont>(&)() noexcept) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think to<std::vector<int>> has the right associated namespaces in order to find this overload in all cases. In range-v3, I needed to have a defaulted function argument (of non-template class type) on to and put the operator| within that type's associated namespace.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks for the reminder, and more importantly the twitter link. I'd intended to dig the thread out to refresh my memory on which parts of the problem are in the spec and which are compiler bugs. (Notably the workaround doesn't work with MSVC.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Huh. I'm certain I got it to work with MSVC on Godbolt. 🤔


template<template<class...> class _ContT, class _IRange>
requires __template_convertible<_ContT, _IRange>
constexpr auto operator|(_IRange&& __r, __template_closure<_ContT>(&)() noexcept) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same feedback here. I have it on good authority[*] that this doesn't work in general.

[*]: https://twitter.com/ericniebler/status/1085600729656549377

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