Skip to content

Commit

Permalink
馃敤 Get off of the buggy Clang Ranges implementation
Browse files Browse the repository at this point in the history
- 馃挌 Improve the CI for Clang-based systems
  • Loading branch information
ThePhD committed Apr 23, 2021
1 parent 4e1f956 commit 16479b1
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 197 deletions.
2 changes: 1 addition & 1 deletion examples/basic/source/rope_transcode_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <iostream>

int main(int, char*[]) {
const std::string_view input = reinterpret_cast<const char*>(u8"锌褉懈胁械褌褋褌胁懈械" + 0);
const std::string_view input = reinterpret_cast<const char*>(&u8"锌褉懈胁械褌褋褌胁懈械"[0]);
const std::u16string_view expected_output = u"锌褉懈胁械褌褋褌胁懈械";

using rope = __gnu_cxx::crope; // rope of char
Expand Down
2 changes: 0 additions & 2 deletions include/ztd/text/basic_text_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ namespace ztd { namespace text {
//////
/// @brief Returns a view over the code points of this type, decoding "on the fly"/"lazily".
///
/// @overload
///
/// @tparam _ViewErrorHandler The type of the passed-in error handler to use for these operations.
///
/// @param[in] __state The state to use for this code point view.
Expand Down
1 change: 0 additions & 1 deletion include/ztd/text/decode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ namespace ztd { namespace text {
constexpr auto basic_decode_into(_Input&& __input, _Encoding&& __encoding, _Output&& __output,
_ErrorHandler&& __error_handler, _State& __state) {
using _UInput = __txt_detail::__remove_cvref_t<_Input>;
using _UOutput = __txt_detail::__remove_cvref_t<_Output>;
using _InputValueType = __txt_detail::__range_value_type_t<_UInput>;
using _IntermediateInput = __txt_detail::__reconstruct_t<::std::conditional_t<::std::is_array_v<_UInput>,
::std::conditional_t<__txt_detail::__is_character_v<_InputValueType>,
Expand Down
8 changes: 4 additions & 4 deletions include/ztd/text/decode_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ namespace ztd { namespace text {
}

template <typename _Input, typename _Output, typename _State, typename _DesiredOutput>
constexpr decode_result<_Input, __txt_detail::__remove_cvref_t<_DesiredOutput>, _State> __replace_result_output(
constexpr decode_result<_Input, __remove_cvref_t<_DesiredOutput>, _State> __replace_result_output(
decode_result<_Input, _Output, _State>&& __result,
_DesiredOutput&&
__desired_output) noexcept(::std::is_nothrow_constructible_v<decode_result<_Input, _Output, _State>,
_Input&&, _DesiredOutput, _State&, encoding_error, ::std::size_t>) {
using _Result = decode_result<_Input, __txt_detail::__remove_cvref_t<_DesiredOutput>, _State>;
using _Result = decode_result<_Input, __remove_cvref_t<_DesiredOutput>, _State>;
return _Result(::std::move(__result.input), ::std::forward<_DesiredOutput>(__desired_output),
__result.state, __result.error_code, __result.handled_errors);
}
Expand Down Expand Up @@ -245,8 +245,8 @@ namespace ztd { namespace text {

template <typename _Encoding, typename _Input, typename _Output, typename _ErrorHandler, typename _State>
inline constexpr bool __is_decode_error_handler_callable_v = __is_detected_v<__detect_callable_handler,
_ErrorHandler, _Encoding, __reconstruct_decode_result_t<__remove_cvref_t<_Input>, _Output, _State>,
::ztd::text::span<code_unit_t<_Encoding>>>;
_ErrorHandler, _Encoding, __reconstruct_decode_result_t<_Input, _Output, _State>,
::ztd::text::span<code_unit_t<__remove_cvref_t<_Encoding>>>>;

template <typename _Encoding, typename _Input, typename _Output, typename _ErrorHandler, typename _State>
inline constexpr bool __is_decode_one_callable_v
Expand Down
22 changes: 14 additions & 8 deletions include/ztd/text/decode_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,24 @@ namespace ztd { namespace text {
return sentinel();
}

//////
/// @brief The reconstruct extension point for rebuilding an encoding view from its iterator and sentinel
/// type.
//////
friend decode_view reconstruct(::std::in_place_type_t<decode_view>, iterator __it, sentinel) {
return decode_view(::std::move(__it));
}

private:
iterator _M_it;
};

//////
/// @brief The reconstruct extension point for rebuilding an encoding view from its iterator and sentinel
/// type.
//////
template <typename _Encoding, typename _Range, typename _ErrorHandler, typename _State>
constexpr decode_view<_Encoding, _Range, _ErrorHandler, _State> reconstruct(
::std::in_place_type_t<decode_view<_Encoding, _Range, _ErrorHandler, _State>>,
typename decode_view<_Encoding, _Range, _ErrorHandler, _State>::iterator __it,
typename decode_view<_Encoding, _Range, _ErrorHandler, _State>::sentinel) noexcept(::std::
is_nothrow_constructible_v<decode_view<_Encoding, _Range, _ErrorHandler, _State>,
typename decode_view<_Encoding, _Range, _ErrorHandler, _State>::iterator&&>) {
return decode_view<_Encoding, _Range, _ErrorHandler, _State>(::std::move(__it));
}

//////
/// @}
//////
Expand Down
4 changes: 2 additions & 2 deletions include/ztd/text/detail/encoding_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ namespace ztd { namespace text {
///
//////
friend constexpr bool operator==(const _Derived& __it, const __encoding_sentinel_t&) {
if constexpr (__it._IsCursorless || (__it._IsInputOrOutput && __it._IsSingleValueType)) {
if constexpr (_IsCursorless || (_IsInputOrOutput && _IsSingleValueType)) {
return __it._M_base_is_empty()
&& static_cast<__base_cursor_cache_size_t>(__txt_detail::_CursorlessSizeSentinel)
== __it.__base_cursor_cache_t::_M_size;
Expand All @@ -436,7 +436,7 @@ namespace ztd { namespace text {
///
//////
friend constexpr bool operator!=(const _Derived& __it, const __encoding_sentinel_t&) {
if constexpr (__it._IsCursorless || (__it._IsInputOrOutput && __it._IsSingleValueType)) {
if constexpr (_IsCursorless || (_IsInputOrOutput && _IsSingleValueType)) {
return !__it._M_base_is_empty()
|| static_cast<__base_cursor_cache_size_t>(__txt_detail::_CursorlessSizeSentinel)
!= __it.__base_cursor_cache_t::_M_size;
Expand Down
5 changes: 0 additions & 5 deletions include/ztd/text/detail/transcode_one.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,11 @@ namespace ztd { namespace text {
typename _ErrorHandler, typename _State>
constexpr auto __basic_encode_one(_Input&& __input, _Encoding&& __encoding, _Output&& __output,
_ErrorHandler& __error_handler, _State& __state) {
using _UInput = __remove_cvref_t<_Input>;
using _UOutput = __remove_cvref_t<_Output>;
using _UEncoding = __remove_cvref_t<_Encoding>;
using _OutputIterator = __range_iterator_t<_UOutput>;
using _Blackhole = unbounded_view<__blackhole_iterator>;


if constexpr (__is_iterator_output_iterator_v<_OutputIterator>) {
return __encoding.encode_one(
::std::forward<_Input>(__input), ::std::forward<_Output>(__output), __error_handler, __state);
Expand Down Expand Up @@ -302,7 +300,6 @@ namespace ztd { namespace text {
_IntermediateContainer& __intermediate, _Output&& __output, _ToEncoding& __to_encoding,
_FromErrorHandler& __from_error_handler, _ToErrorHandler& __to_error_handler, _FromState& __from_state,
_ToState& __to_state) {
using _UInput = __remove_cvref_t<_Input>;
using _WorkingIntermediate
= ::std::conditional_t<__is_iterator_concept_or_better_v<contiguous_iterator_tag,
__range_iterator_t<_IntermediateContainer>>,
Expand Down Expand Up @@ -660,7 +657,6 @@ namespace ztd { namespace text {
typename _State>
constexpr auto __basic_count_code_points_one(_Input&& __input, _Encoding&& __encoding,
_OutputContainer& __output, _ErrorHandler&& __error_handler, _State& __state) {
using _UInput = __remove_cvref_t<_Input>;
using _Result = count_result<__reconstruct_t<_Input>, _State>;

auto __intermediate_result = __basic_encode_one<__consume::__no>(::std::forward<_Input>(__input),
Expand Down Expand Up @@ -689,7 +685,6 @@ namespace ztd { namespace text {
typename _State>
constexpr auto __basic_count_code_units_one(_Input&& __input, _Encoding&& __encoding,
_OutputCodePointContainer& __output, _ErrorHandler&& __error_handler, _State& __state) {
using _UInput = __remove_cvref_t<_Input>;
using _Result = count_result<__reconstruct_t<_Input>, _State>;

auto __intermediate_result = __basic_decode_one<__consume::__no>(::std::forward<_Input>(__input),
Expand Down
1 change: 0 additions & 1 deletion include/ztd/text/encode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ namespace ztd { namespace text {
constexpr auto basic_encode_into(_Input&& __input, _Encoding&& __encoding, _Output&& __output,
_ErrorHandler&& __error_handler, _State& __state) {
using _UInput = __txt_detail::__remove_cvref_t<_Input>;
using _UOutput = __txt_detail::__remove_cvref_t<_Output>;
using _InputValueType = __txt_detail::__range_value_type_t<_UInput>;
// using _OutputValueType = __txt_detail::__range_value_type_t<_UOutput>;
using _IntermediateInput = __txt_detail::__reconstruct_t<::std::conditional_t<::std::is_array_v<_UInput>,
Expand Down
12 changes: 6 additions & 6 deletions include/ztd/text/encode_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ namespace ztd { namespace text {
}

template <typename _Input, typename _Output, typename _State, typename _DesiredOutput>
constexpr encode_result<_Input, __txt_detail::__remove_cvref_t<_DesiredOutput>, _State> __replace_result_output(
encode_result<_Input, _Output, _State>&& __result,
constexpr encode_result<_Input, __remove_cvref_t<_DesiredOutput>, _State>
__replace_result_output(encode_result<_Input, _Output, _State>&& __result,
_DesiredOutput&&
__desired_output) noexcept(::std::is_nothrow_constructible_v<encode_result<_Input, _Output, _State>,
_Input&&, _DesiredOutput, _State&, encoding_error, ::std::size_t>) {
using _Result = encode_result<_Input, __txt_detail::__remove_cvref_t<_DesiredOutput>, _State>;
using _Result = encode_result<_Input, __remove_cvref_t<_DesiredOutput>, _State>;
return _Result(::std::move(__result.input), ::std::forward<_DesiredOutput>(__desired_output),
__result.state, __result.error_code, __result.handled_errors);
}
Expand Down Expand Up @@ -241,9 +241,9 @@ namespace ztd { namespace text {
}

template <typename _Encoding, typename _Input, typename _Output, typename _ErrorHandler, typename _State>
inline constexpr bool __is_encode_error_handler_callable_v = __is_detected_v<__detect_callable_handler,
_ErrorHandler, _Encoding, __reconstruct_encode_result_t<__remove_cvref_t<_Input>, _Output, _State>,
::ztd::text::span<code_unit_t<_Encoding>>>;
inline constexpr bool __is_encode_error_handler_callable_v
= __is_detected_v<__detect_callable_handler, _ErrorHandler, _Encoding,
__reconstruct_encode_result_t<_Input, _Output, _State>, ::ztd::text::span<code_unit_t<__remove_cvref_t<_Encoding>>>>;

template <typename _Encoding, typename _Input, typename _Output, typename _ErrorHandler, typename _State>
inline constexpr bool __is_encode_one_callable_v
Expand Down
22 changes: 14 additions & 8 deletions include/ztd/text/encode_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,24 @@ namespace ztd { namespace text {
return sentinel();
}

//////
/// @brief The reconstruct extension point for rebuilding an encoding view from its iterator and sentinel
/// type.
//////
friend constexpr encode_view reconstruct(::std::in_place_type_t<encode_view>, iterator __it, sentinel) {
return encode_view(::std::move(__it));
}

private:
iterator _M_it;
};

//////
/// @brief The reconstruct extension point for rebuilding an encoding view from its iterator and sentinel
/// type.
//////
template <typename _Encoding, typename _Range, typename _ErrorHandler, typename _State>
constexpr encode_view<_Encoding, _Range, _ErrorHandler, _State> reconstruct(
::std::in_place_type_t<encode_view<_Encoding, _Range, _ErrorHandler, _State>>,
typename encode_view<_Encoding, _Range, _ErrorHandler, _State>::iterator __it,
typename encode_view<_Encoding, _Range, _ErrorHandler, _State>::sentinel) noexcept(::std::
is_nothrow_constructible_v<encode_view<_Encoding, _Range, _ErrorHandler, _State>,
typename encode_view<_Encoding, _Range, _ErrorHandler, _State>::iterator&&>) {
return encode_view<_Encoding, _Range, _ErrorHandler, _State>(::std::move(__it));
}

//////
/// @}
//////
Expand Down
8 changes: 3 additions & 5 deletions include/ztd/text/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ namespace ztd { namespace text {
_Result(__txt_detail::__reconstruct(::std::in_place_type<_UInputRange>,
::std::move(__init), ::std::move(__inlast)),
__txt_detail::__reconstruct(::std::in_place_type<_UOutputRange>,
::std::move(__outit), ::std::move(__outlast)::std::move(__outit),
::std::move(__outlast)),
::std::move(__outit), ::std::move(__outlast)),
__s, encoding_error::invalid_sequence),
::ztd::text::span<code_point, 1>(&__codepoint, 1));
}
Expand All @@ -393,9 +392,8 @@ namespace ztd { namespace text {
if (__outit == __outlast) {
execution __self {};
return __error_handler(__self,
_Result(__txt_detail::__reconstruct(
::std::in_place_type<_UInputRange>::std::move(__outit),
::std::move(__outlast)),
_Result(__txt_detail::__reconstruct(::std::in_place_type<_UInputRange>,
::std::move(__init), ::std::move(__inlast)),
__txt_detail::__reconstruct(::std::in_place_type<_UOutputRange>,
::std::move(__outit), ::std::move(__outlast)),
__s, encoding_error::insufficient_output_space),
Expand Down
12 changes: 6 additions & 6 deletions include/ztd/text/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ namespace ztd { namespace text {
//////
template <typename _Encoding>
constexpr decode_state_t<__txt_detail::__remove_cvref_t<_Encoding>> make_decode_state_with(_Encoding& __encoding,
const decode_state_t<__txt_detail::__remove_cvref_t<_Encoding>>& __encode_state) noexcept {
const encode_state_t<__txt_detail::__remove_cvref_t<_Encoding>>& __encode_state) noexcept {
using _UEncoding = __txt_detail::__remove_cvref_t<_Encoding>;
using _DecodeState = decode_state_t<_UEncoding>;
using _EncodeState = encode_state_t<_UEncoding>;
if constexpr (is_encode_state_independent_v<_UEncoding>) {
if constexpr (::std::is_constructible_v<_EncodeState, _DecodeState>) {
if constexpr (is_decode_state_independent_v<_UEncoding>) {
if constexpr (::std::is_constructible_v<_EncodeState, const _DecodeState&>) {
(void)__encoding;
return _DecodeState(__encode_state);
}
Expand All @@ -211,7 +211,7 @@ namespace ztd { namespace text {
}
}
else {
if constexpr (::std::is_constructible_v<_EncodeState, _DecodeState>) {
if constexpr (::std::is_constructible_v<_EncodeState, const _UEncoding&, const _DecodeState&>) {
return _DecodeState(__encoding, __encode_state);
}
else {
Expand All @@ -236,7 +236,7 @@ namespace ztd { namespace text {
using _DecodeState = decode_state_t<_UEncoding>;
using _EncodeState = encode_state_t<_UEncoding>;
if constexpr (is_encode_state_independent_v<_UEncoding>) {
if constexpr (::std::is_constructible_v<_EncodeState, _DecodeState>) {
if constexpr (::std::is_constructible_v<_EncodeState, const _DecodeState&>) {
(void)__encoding;
return _EncodeState(__decode_state);
}
Expand All @@ -247,7 +247,7 @@ namespace ztd { namespace text {
}
}
else {
if constexpr (::std::is_constructible_v<_EncodeState, _DecodeState>) {
if constexpr (::std::is_constructible_v<_EncodeState, const _UEncoding&, const _DecodeState&>) {
return _EncodeState(__encoding, __decode_state);
}
else {
Expand Down
1 change: 0 additions & 1 deletion include/ztd/text/transcode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ namespace ztd { namespace text {
_ToEncoding&& __to_encoding, _FromErrorHandler&& __from_error_handler, _ToErrorHandler&& __to_error_handler,
_FromState& __from_state, _ToState& __to_state) {
using _UInput = __txt_detail::__remove_cvref_t<_Input>;
using _UOutput = __txt_detail::__remove_cvref_t<_Output>;
using _InputValueType = __txt_detail::__range_value_type_t<_UInput>;
using _WorkingInput = __txt_detail::__reconstruct_t<::std::conditional_t<::std::is_array_v<_UInput>,
::std::conditional_t<__txt_detail::__is_character_v<_InputValueType>,
Expand Down
2 changes: 1 addition & 1 deletion include/ztd/text/transcode_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ namespace ztd { namespace text {
///
//////
friend constexpr bool operator!=(const transcode_iterator& __it, const transcode_sentinel_t&) {
if constexpr (__it._IsCursorless || (__it._IsInputOrOutput && __it._IsSingleValueType)) {
if constexpr (_IsCursorless || (_IsInputOrOutput && _IsSingleValueType)) {
return !__it._M_base_is_empty()
|| static_cast<__base_cursor_cache_size_t>(__txt_detail::_CursorlessSizeSentinel)
!= __it.__base_cursor_cache_t::_M_size;
Expand Down
18 changes: 8 additions & 10 deletions include/ztd/text/transcode_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ namespace ztd { namespace text {
encoding_error __error_code
= encoding_error::ok) noexcept(noexcept(stateless_transcode_result(::std::forward<_ArgInput>(__input),
::std::forward<_ArgOutput>(__output), __error_code, __error_code != encoding_error::ok)))
: stateless_transcode_result(::std::forward<_ArgInput>(__input), ::std::forward<_ArgOutput>(__output), __error_code,
__error_code != encoding_error::ok) {
: stateless_transcode_result(::std::forward<_ArgInput>(__input), ::std::forward<_ArgOutput>(__output),
__error_code, __error_code != encoding_error::ok) {
}

//////
Expand Down Expand Up @@ -219,21 +219,19 @@ namespace ztd { namespace text {
}

template <typename _Input, typename _Output, typename _FromState, typename _ToState, typename _DesiredOutput>
constexpr transcode_result<_Input, __txt_detail::__remove_cvref_t<_DesiredOutput>, _FromState,
_ToState>
constexpr transcode_result<_Input, __remove_cvref_t<_DesiredOutput>, _FromState, _ToState>
__replace_result_output(transcode_result<_Input, _Output, _FromState, _ToState>&& __result,
_DesiredOutput&& __desired_output) noexcept(::std::
is_nothrow_constructible_v<transcode_result<_Input, _Output, _FromState, _ToState>,
_Input&&, _DesiredOutput, _FromState&, _ToState&, encoding_error, ::std::size_t>) {
using _Result = transcode_result<_Input, __txt_detail::__remove_cvref_t<_DesiredOutput>,
_FromState, _ToState>;
is_nothrow_constructible_v<transcode_result<_Input, _Output, _FromState, _ToState>, _Input&&,
_DesiredOutput, _FromState&, _ToState&, encoding_error, ::std::size_t>) {
using _Result = transcode_result<_Input, __remove_cvref_t<_DesiredOutput>, _FromState, _ToState>;
return _Result(::std::move(__result.input), ::std::forward<_DesiredOutput>(__desired_output),
__result.from_state, __result.to_state, __result.error_code, __result.handled_errors);
}

template <typename _InputRange, typename _OutputRange, typename _FromState, typename _ToState>
using __reconstruct_transcode_result_t = transcode_result<__reconstruct_t<_InputRange>,
__reconstruct_t<_OutputRange>, _FromState, _ToState>;
using __reconstruct_transcode_result_t
= transcode_result<__reconstruct_t<_InputRange>, __reconstruct_t<_OutputRange>, _FromState, _ToState>;

template <typename _InputRange, typename _OutputRange, typename _ToState, typename _FromState,
typename _InFirst, typename _InLast, typename _OutFirst, typename _OutLast, typename _ArgToState,
Expand Down

0 comments on commit 16479b1

Please sign in to comment.