@@ -92,8 +92,13 @@ enum class utf_transcoding_error {
9292 invalid_utf8_leading_byte
9393};
9494
95- template <std::ranges::input_range V, bool OrError, exposition_only_code_unit ToType>
96- requires std::ranges::view<V> && exposition_only_code_unit<std::ranges::range_value_t <V>>
95+ enum class to_utf_view_error_kind : bool {
96+ replacement,
97+ expected
98+ };
99+
100+ template <std::ranges::input_range V, to_utf_view_error_kind E, exposition_only_code_unit ToType>
101+ requires std::ranges::view<V> && exposition_only_code_unit<std::ranges::range_value_t <V>>
97102/* !PAPER */
98103class exposition_only_to_utf_view_impl {
99104/* PAPER */
@@ -206,12 +211,12 @@ class exposition_only_to_utf_view_impl {
206211 /* PAPER */
207212};
208213
209- template <std::ranges::input_range V, bool OrError , exposition_only_code_unit ToType>
214+ template <std::ranges::input_range V, to_utf_view_error_kind E , exposition_only_code_unit ToType>
210215 requires std::ranges::view<V> && exposition_only_code_unit<std::ranges::range_value_t <V>>
211216template <bool Const>
212- /* PAPER: class @*to-utf-view-impl*@<V, OrError , ToType>::@*iterator*@ { */
217+ /* PAPER: class @*to-utf-view-impl*@<V, E , ToType>::@*iterator*@ { */
213218/* !PAPER */
214- struct exposition_only_to_utf_view_impl <V, OrError , ToType>::exposition_only_iterator : detail::iter_category_impl<V> {
219+ struct exposition_only_to_utf_view_impl <V, E , ToType>::exposition_only_iterator : detail::iter_category_impl<V> {
215220/* PAPER */
216221private:
217222 using exposition_only_Parent = exposition_only_maybe_const<Const, exposition_only_to_utf_view_impl>; // @*exposition only*@
@@ -238,7 +243,7 @@ struct exposition_only_to_utf_view_impl<V, OrError, ToType>::exposition_only_ite
238243 using iterator_concept = decltype (iter_concept_impl());
239244 /* PAPER */
240245 using value_type =
241- std::conditional_t <OrError , std::expected<ToType, utf_transcoding_error>, ToType>;
246+ std::conditional_t <E == to_utf_view_error_kind::expected , std::expected<ToType, utf_transcoding_error>, ToType>;
242247 using reference_type = value_type;
243248 using difference_type = ptrdiff_t ;
244249
@@ -261,7 +266,7 @@ struct exposition_only_to_utf_view_impl<V, OrError, ToType>::exposition_only_ite
261266
262267 /* PAPER */
263268
264- template <std::ranges::input_range V2, bool OrError2 , exposition_only_code_unit ToType2>
269+ template <std::ranges::input_range V2, to_utf_view_error_kind E2 , exposition_only_code_unit ToType2>
265270 requires std::ranges::view<V2> && exposition_only_code_unit<std::ranges::range_value_t <V2>>
266271 friend class exposition_only_to_utf_view_impl ; // @*exposition only*@
267272
@@ -294,7 +299,7 @@ struct exposition_only_to_utf_view_impl<V, OrError, ToType>::exposition_only_ite
294299 /* PAPER: constexpr value_type operator*() const; */
295300 /* !PAPER */
296301 constexpr value_type operator *() const {
297- if constexpr (OrError ) {
302+ if constexpr (E == to_utf_view_error_kind::expected ) {
298303 if (!success_.has_value ()) {
299304 return std::unexpected{success_.error ()};
300305 }
@@ -303,7 +308,7 @@ struct exposition_only_to_utf_view_impl<V, OrError, ToType>::exposition_only_ite
303308 }
304309 /* PAPER */
305310
306- constexpr exposition_only_iterator& operator ++() requires (OrError )
311+ constexpr exposition_only_iterator& operator ++() requires (E == to_utf_view_error_kind::expected )
307312 {
308313 if (!exposition_only_success ()) {
309314 /* !PAPER */
@@ -318,7 +323,7 @@ struct exposition_only_to_utf_view_impl<V, OrError, ToType>::exposition_only_ite
318323 return *this ;
319324 }
320325
321- constexpr exposition_only_iterator& operator ++() requires (!OrError )
326+ constexpr exposition_only_iterator& operator ++() requires (E == to_utf_view_error_kind::replacement )
322327 {
323328 exposition_only_advance_one ();
324329 return *this ;
@@ -395,11 +400,11 @@ struct exposition_only_to_utf_view_impl<V, OrError, ToType>::exposition_only_ite
395400 return std::ranges::end (parent_->base_ );
396401 }
397402
398- /* PAPER: constexpr expected<void, utf_transcoding_error> @*success*@() const noexcept requires(OrError ); // @*exposition only*@ */
403+ /* PAPER: constexpr expected<void, utf_transcoding_error> @*success*@() const noexcept requires(E == to_utf_view_error_kind::expected ); // @*exposition only*@ */
399404 /* !PAPER */
400405
401406 constexpr bool exposition_only_success () const noexcept // @*exposition only*@
402- requires(OrError )
407+ requires(E == to_utf_view_error_kind::expected )
403408 {
404409 return !!success_;
405410 }
@@ -808,7 +813,7 @@ struct exposition_only_to_utf_view_impl<V, OrError, ToType>::exposition_only_ite
808813 current_ = read_reverse_impl_result.new_curr ;
809814 assert (buf_.size ());
810815 buf_index_ = buf_.size () - 1 ;
811- if constexpr (OrError ) {
816+ if constexpr (E == to_utf_view_error_kind::expected ) {
812817 if (!success_.has_value ()) {
813818 buf_index_ = 0 ;
814819 }
@@ -818,12 +823,12 @@ struct exposition_only_to_utf_view_impl<V, OrError, ToType>::exposition_only_ite
818823 /* PAPER */
819824};
820825
821- template <std::ranges::input_range V, bool OrError , exposition_only_code_unit ToType>
826+ template <std::ranges::input_range V, to_utf_view_error_kind E , exposition_only_code_unit ToType>
822827 requires std::ranges::view<V> && exposition_only_code_unit<std::ranges::range_value_t <V>>
823828template <bool Const>
824- /* PAPER: class @*to-utf-view-impl*@<V, OrError , ToType>::@*sentinel*@ { */
829+ /* PAPER: class @*to-utf-view-impl*@<V, E , ToType>::@*sentinel*@ { */
825830/* !PAPER */
826- struct exposition_only_to_utf_view_impl <V, OrError , ToType>::exposition_only_sentinel {
831+ struct exposition_only_to_utf_view_impl <V, E , ToType>::exposition_only_sentinel {
827832 /* PAPER */
828833private:
829834 using exposition_only_Parent = exposition_only_maybe_const<Const, exposition_only_to_utf_view_impl>; // @*exposition only*@
@@ -909,7 +914,7 @@ class to_utf8_view : public std::ranges::view_interface<to_utf8_view<V>> {
909914 /* PAPER */
910915
911916private:
912- exposition_only_to_utf_view_impl<V, false , char8_t > impl_; // @*exposition only*@
917+ exposition_only_to_utf_view_impl<V, to_utf_view_error_kind::replacement , char8_t > impl_; // @*exposition only*@
913918};
914919
915920template <class R >
@@ -972,7 +977,7 @@ class to_utf8_or_error_view
972977 /* PAPER */
973978
974979private:
975- exposition_only_to_utf_view_impl<V, true , char8_t > impl_; // @*exposition only*@
980+ exposition_only_to_utf_view_impl<V, to_utf_view_error_kind::expected , char8_t > impl_; // @*exposition only*@
976981};
977982
978983template <class R >
@@ -1034,7 +1039,7 @@ class to_utf16_view : public std::ranges::view_interface<to_utf16_view<V>> {
10341039 /* PAPER */
10351040
10361041private:
1037- exposition_only_to_utf_view_impl<V, false , char16_t > impl_; // @*exposition only*@
1042+ exposition_only_to_utf_view_impl<V, to_utf_view_error_kind::replacement , char16_t > impl_; // @*exposition only*@
10381043};
10391044
10401045template <class R >
@@ -1097,7 +1102,7 @@ class to_utf16_or_error_view
10971102 /* PAPER */
10981103
10991104private:
1100- exposition_only_to_utf_view_impl<V, true , char16_t > impl_; // @*exposition only*@
1105+ exposition_only_to_utf_view_impl<V, to_utf_view_error_kind::expected , char16_t > impl_; // @*exposition only*@
11011106};
11021107
11031108template <class R >
@@ -1165,7 +1170,7 @@ class to_utf32_view : public std::ranges::view_interface<to_utf32_view<V>> {
11651170 /* PAPER */
11661171
11671172private:
1168- exposition_only_to_utf_view_impl<V, false , char32_t > impl_; // @*exposition only*@
1173+ exposition_only_to_utf_view_impl<V, to_utf_view_error_kind::replacement , char32_t > impl_; // @*exposition only*@
11691174};
11701175
11711176template <class R >
@@ -1234,7 +1239,7 @@ class to_utf32_or_error_view
12341239 /* PAPER */
12351240
12361241private:
1237- exposition_only_to_utf_view_impl<V, true , char32_t > impl_; // @*exposition only*@
1242+ exposition_only_to_utf_view_impl<V, to_utf_view_error_kind::expected , char32_t > impl_; // @*exposition only*@
12381243};
12391244
12401245template <class R >
@@ -1244,9 +1249,9 @@ to_utf32_or_error_view(R&&) -> to_utf32_or_error_view<std::views::all_t<R>>;
12441249
12451250namespace detail {
12461251
1247- template <class V , bool OrError , exposition_only_code_unit ToType>
1252+ template <class V , to_utf_view_error_kind E , exposition_only_code_unit ToType>
12481253 using to_utf_view = std::conditional_t <
1249- OrError ,
1254+ E == to_utf_view_error_kind::expected ,
12501255 std::conditional_t <
12511256 std::is_same_v<ToType, char8_t >, to_utf8_or_error_view<V>,
12521257 std::conditional_t <std::is_same_v<ToType, char16_t >, to_utf16_or_error_view<V>,
@@ -1258,8 +1263,8 @@ namespace detail {
12581263 std::conditional_t <std::is_same_v<ToType, char32_t >,
12591264 to_utf32_view<V>, void >>>>;
12601265
1261- template <bool OrError , exposition_only_code_unit ToType>
1262- struct to_utf_impl : std::ranges::range_adaptor_closure<to_utf_impl<OrError , ToType>> {
1266+ template <to_utf_view_error_kind E , exposition_only_code_unit ToType>
1267+ struct to_utf_impl : std::ranges::range_adaptor_closure<to_utf_impl<E , ToType>> {
12631268 template <class R >
12641269 constexpr auto operator ()(R&& r) const {
12651270 using T = std::remove_cvref_t <R>;
@@ -1273,33 +1278,33 @@ namespace detail {
12731278 --last;
12741279 }
12751280 std::ranges::subrange subrange (first, last);
1276- return to_utf_view<decltype (subrange), OrError , ToType>(std::move (subrange));
1281+ return to_utf_view<decltype (subrange), E , ToType>(std::move (subrange));
12771282 } else {
12781283 auto view = std::views::all (std::forward<R>(r));
1279- return to_utf_view<decltype (view), OrError , ToType>(std::move (view));
1284+ return to_utf_view<decltype (view), E , ToType>(std::move (view));
12801285 }
12811286 }
12821287 };
12831288
12841289} // namespace detail
12851290
12861291template <exposition_only_code_unit ToType>
1287- inline constexpr detail::to_utf_impl<false , ToType> to_utf;
1292+ inline constexpr detail::to_utf_impl<to_utf_view_error_kind::replacement , ToType> to_utf;
12881293
1289- inline constexpr detail::to_utf_impl<false , char8_t > to_utf8;
1294+ inline constexpr detail::to_utf_impl<to_utf_view_error_kind::replacement , char8_t > to_utf8;
12901295
1291- inline constexpr detail::to_utf_impl<false , char16_t > to_utf16;
1296+ inline constexpr detail::to_utf_impl<to_utf_view_error_kind::replacement , char16_t > to_utf16;
12921297
1293- inline constexpr detail::to_utf_impl<false , char32_t > to_utf32;
1298+ inline constexpr detail::to_utf_impl<to_utf_view_error_kind::replacement , char32_t > to_utf32;
12941299
12951300template <exposition_only_code_unit ToType>
1296- inline constexpr detail::to_utf_impl<true , ToType> to_utf_or_error;
1301+ inline constexpr detail::to_utf_impl<to_utf_view_error_kind::expected , ToType> to_utf_or_error;
12971302
1298- inline constexpr detail::to_utf_impl<true , char8_t > to_utf8_or_error;
1303+ inline constexpr detail::to_utf_impl<to_utf_view_error_kind::expected , char8_t > to_utf8_or_error;
12991304
1300- inline constexpr detail::to_utf_impl<true , char16_t > to_utf16_or_error;
1305+ inline constexpr detail::to_utf_impl<to_utf_view_error_kind::expected , char16_t > to_utf16_or_error;
13011306
1302- inline constexpr detail::to_utf_impl<true , char32_t > to_utf32_or_error;
1307+ inline constexpr detail::to_utf_impl<to_utf_view_error_kind::expected , char32_t > to_utf32_or_error;
13031308
13041309/* PAPER: namespace views { */
13051310/* PAPER: */
0 commit comments