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

PL247 22.07.3 [views.span] span::c/begin/end return type confusion LWG 3320 #243

Closed
wg21bot opened this issue Oct 24, 2019 · 6 comments · Fixed by cplusplus/draft#3748
Closed
Labels
accepted LWG Library ranges std::ranges
Milestone

Comments

@wg21bot
Copy link
Collaborator

wg21bot commented Oct 24, 2019

span<T> provides a const-qualified begin() method and cbegin() method that produces a different result if T is not const-qualifed:

  1. begin() produces mutable iterator over T (as if T*)
  2. cbegin() preduces const iterator over T (as if T const*)
    As consequence for the object s of type span<T>, the call to the std::cbegin(s)/std::ranges::cbegin(s) produces different result than s.cbegin().

Proposed change:
Change span<T> members cbegin()/cend()/crbegin()/crend()/const_iterator to be equivalent to begin()/end()/rbegin()/rend()/iterator respectivelly.

@wg21bot wg21bot added the LEWG Library Evolution label Oct 24, 2019
@wg21bot wg21bot added the ranges std::ranges label Oct 25, 2019
@tituswinters
Copy link

LEWG in Belfast: We would like LWG to drop cbegin/cend/crbegin/crend, const_iterator, const_reverse_iterator from span. (Consulting with the author of PL247, this would resolve their concerns.)

@tituswinters tituswinters added LWG Library and removed LEWG Library Evolution labels Nov 5, 2019
@JeffGarland
Copy link
Member

LWG small group Tuesday Belfast - need an LWG issue - assignment made.

@Dani-Hub
Copy link
Member

Dani-Hub commented Nov 6, 2019

The associated issue is LWG 3320

@JeffGarland
Copy link
Member

Issue processed during Wed night issue processing in Belfast and set to Ready.

@jensmaurer jensmaurer changed the title PL247 22.07.3 [views.span] span::c/begin/end return type confusion PL247 22.07.3 [views.span] span::c/begin/end return type confusion LWG 3320 Nov 7, 2019
@mclow mclow added the accepted label Jan 31, 2020
@bishopnator
Copy link

bishopnator commented Jun 12, 2020

Removed const_iterator type from gsl::span causes problems with boost::range - following function is not possible to compile:

#include <boost/adaptors/indexed.hpp>
#include <gsl/span>

void printPairs(const gsl::span<int>& nums)
{
   for(const auto& element : nums | boost::adaptors::indexed(0))
   {
       printf_s("%d - %d\n", static_cast<int>(element.index()), element.value());
   }
}

I tried several signatures and none of them work:

void printPairs(const gsl::span<int>& nums)
void printPairs(gsl::span<int>& nums)
void printPairs(gsl::span<int> nums)

It is necessary to construct new range using boost::make_iterator_range(nums.begin(), nums.end()) and then it works .. but it is IMO not nice.

@jensmaurer
Copy link
Member

jensmaurer commented Jun 12, 2020

@bishopnator, This issue tracker is for administratively tracking the progress of NB comments against C++20. The processing has finished and C++20 is in its final stages of balloting before publication.

Please use other forums for technical discussions, e.g. the appropriate committee reflector or the lwgchair address for submitting library issues. Beyond that, I'd like to point out that entities in namespace "gsl" are not in scope for the C++ standard.

@jensmaurer jensmaurer added this to the CD C++20 milestone Sep 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted LWG Library ranges std::ranges
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants