Skip to content

Commit

Permalink
fix conversion constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
huixie90 committed Sep 23, 2023
1 parent bee7554 commit 572eb2d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
13 changes: 8 additions & 5 deletions concat.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "`views::concat`"
document: D2542R6
date: 2023-09-18
document: P2542R6
date: 2023-09-23
audience: SG9, LEWG, LWG
author:
- name: Hui Xie
Expand All @@ -17,6 +17,8 @@ toc: true

- remove `bidirectional_range` support for `!common_range && random_access_range && sized_range`
- remove `random_access_range` support for `!common_range && random_access_range && sized_range`
- fix const-conversion constructor
- Various wording fixes

## R5

Expand Down Expand Up @@ -1181,15 +1183,16 @@ explicit constexpr @_iterator_@(
:::
```cpp
constexpr @_iterator_@(@_iterator_@<!Const> i)
constexpr @_iterator_@(@_iterator_@<!Const> it)
requires Const &&
(convertible_to<iterator_t<Views>, iterator_t<const Views>>&&...);
```

:::bq

[8]{.pnum} *Effects*: Initializes `@*parent_*@` with `i.@*parent_*@`, and
initializes `@*it_*@` with `std::move(i.@*it_*@)`.
[8]{.pnum} *Effects*: Initializes `@*parent_*@` with `it.@*parent_*@`, and
let `@*i*@` be `it.@*it_*@.index()`, initializes `@*it_*@` with
`@*base-iter*@(in_place_index<@*i*@>, get<@*i*@>(std::move(it.@*it_*@)))`

:::

Expand Down
4 changes: 3 additions & 1 deletion impl/concat/concat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ class concat_view : public view_interface<concat_view<Views...>> {
constexpr iterator(iterator<!Const> i) requires Const &&
(convertible_to<iterator_t<Views>, iterator_t<const Views>>&&...)
// [TODO] noexcept specs?
: parent_{i.parent_}, it_{std::move(i.it_)} {}
: parent_{i.parent_}, it_{xo::visit_i(std::move(i.it_), [](auto I, auto&& it){
return BaseIt(in_place_index<I>, std::move(it));
})} {}

constexpr decltype(auto) operator*() const {
using reference = xo::concat_reference_t<__maybe_const<Const, Views>...>;
Expand Down
2 changes: 1 addition & 1 deletion impl/concat/test/issues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ TEST_POINT("#4") {
[[maybe_unused]] decltype(it) it_copy(it); // OK
[[maybe_unused]] decltype(cit) cit_copy(cit); // OK
// [[maybe_unused]] decltype(it) it_copy2(cit); // NOK by design
// [[maybe_unused]] decltype(cit) cit_copy2(it); // NOK bug!
[[maybe_unused]] decltype(cit) cit_copy2(it); // NOK bug!
}

0 comments on commit 572eb2d

Please sign in to comment.