Skip to content

Commit

Permalink
πŸ›  Windows has issues with decltype SFINAE accesses.
Browse files Browse the repository at this point in the history
β€” πŸ›  πŸ’­ "So most things must be properly forwarded and we cannot rely on private members in base classes! Which is REALLY bloody annoying, but that's where we're at with compilers these days."
  • Loading branch information
ThePhD committed Dec 23, 2022
1 parent fa8d465 commit fe03443
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 61 deletions.
11 changes: 9 additions & 2 deletions examples/documentation/snippets/include/my_utf16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include <utility>

class my_utf16 : private ztd::text::utf16_t {
private:
using base_t = ztd::text::utf16_t;

public:
// Lucky 7 Members
static inline constexpr std::size_t max_code_points = 1;
Expand All @@ -47,8 +50,12 @@ class my_utf16 : private ztd::text::utf16_t {

// Import base implementation here,
// to save on the implementation work!
using ztd::text::utf16_t::decode_one;
using ztd::text::utf16_t::encode_one;
using base_t::decode_one;
using base_t::encode_one;

// Import additional methods
using base_t::replacement_code_points;
using base_t::replacement_code_units;

// ❗ Special input skip member!!
// If this function is present and callable, it will
Expand Down
12 changes: 12 additions & 0 deletions include/ztd/text/basic_encoding_scheme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <ztd/text/state.hpp>
#include <ztd/text/code_point.hpp>
#include <ztd/text/code_unit.hpp>
#include <ztd/text/skip_input_error.hpp>
#include <ztd/text/detail/constant_encoding_traits.hpp>
#include <ztd/text/detail/basic_encoding_scheme_includes.hpp>

Expand Down Expand Up @@ -293,6 +294,17 @@ namespace ztd { namespace text {
return ::ztd::text::contains_unicode_encoding(this->base());
}

//////
/// @brief Skips any consecutive input errors in the encoded input, where possible.
///
/// @remarks This Is only callable if the function call exists on the wrapped encoding.
template <typename _Result,
::std::enable_if_t<is_input_error_skippable_v<const encoding_type&, _Result>>* = nullptr>
constexpr decltype(auto) skip_input_error(_Result&& __result) const noexcept(noexcept(
::ztd::text::skip_input_error(::std::declval<const encoding_type&>(), ::std::declval<_Result>()))) {
return ::ztd::text::skip_input_error(this->base(), ::std::forward<_Result>(__result));
}

//////
/// @brief Decodes a single complete unit of information as code points and produces a result with the
/// input and output ranges moved past what was successfully read and written; or, produces an error and
Expand Down
4 changes: 2 additions & 2 deletions include/ztd/text/impl/execution_cuchar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ namespace ztd { namespace text {

code_point __codepoint = *__in_it;
::ztd::ranges::iter_advance(__in_it);
code_unit __intermediary_output[(MB_LEN_MAX * 2)] {};
code_unit __intermediary_output[(MB_LEN_MAX)] {};
::std::size_t __res = ZTD_UCHAR_ACCESSOR_I_ c32rtomb(
__intermediary_output, __codepoint, ::std::addressof(__s.__narrow_state));
if constexpr (__call_error_handler) {
Expand Down Expand Up @@ -435,7 +435,7 @@ namespace ztd { namespace text {
}
}

code_unit __intermediary_input[max_code_units * 2] {};
code_unit __intermediary_input[max_code_units] {};
#if ZTD_IS_ON(ZTD_PLATFORM_WINDOWS) && ZTD_IS_OFF(ZTD_COMPILER_MINGW)
__intermediary_input[0] = *__in_it;
::ztd::ranges::iter_advance(__in_it);
Expand Down
6 changes: 6 additions & 0 deletions include/ztd/text/impl/wide_execution_windows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ namespace ztd { namespace text {

// Inherit some funtions
using __base_t::skip_input_error;

// Inherit some funtions
using __base_t::replacement_code_points;

// Inherit some funtions
using __base_t::replacement_code_units;
};

} // namespace __txt_impl
Expand Down
2 changes: 1 addition & 1 deletion include/ztd/text/literal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace ztd { namespace text {

//////
/// @brief The encoding of string literal_ts ( e.g. @c "πŸ‘" ) at compile time.
class literal_t : private __txt_detail::__literal {
class literal_t : public __txt_detail::__literal {
private:
using __base_t = __txt_detail::__literal;

Expand Down
115 changes: 60 additions & 55 deletions include/ztd/text/transcode.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/ztd/text/wide_literal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace ztd { namespace text {

//////
/// @brief The encoding of wide string literal_ts ( e.g. @c "πŸ‘" ) at compile time.
class wide_literal_t : private __txt_detail::__wide_literal {
class wide_literal_t : public __txt_detail::__wide_literal {
private:
using __base_t = __txt_detail::__wide_literal;

Expand Down

0 comments on commit fe03443

Please sign in to comment.