26 namespace concepts::writeable_output_details {
28 constexpr T *copy_to_buffer( T *buff, daw::string_view source ) {
29 if( DAW_IS_CONSTANT_EVALUATED_COMPAT( ) ) {
30 daw::algorithm::transform_n( source.data( ),
35 return static_cast<T>( c );
38 memcpy( buff, source.data( ), source.size( ) );
40 return buff + source.size( );
44 template<
typename T,
typename =
void>
45 inline constexpr bool has_capacity_reserve_v =
false;
48 inline constexpr bool has_capacity_reserve_v<
49 T, std::void_t<decltype( std::declval<T &>( ).capacity( ) ),
50 decltype( std::declval<T &>( ).reserve(
51 std::size_t{ } ) )>> =
true;
54 DAW_CPP20_CONCEPT is_byte_type_v =
55 std::is_same_v<T, std::byte> or std::is_same_v<T, unsigned char>;
58 DAW_CPP20_CONCEPT is_char_sized_character_v =
59 std::is_same_v<T, char>
60#if defined( __cpp_lib_char8_t )
61#if __cpp_lib_char8_t >= 201907L
62 or std::is_same_v<T, char8_t>
67 template<
typename T,
typename CharT>
68 using span_like_range_test =
69 decltype( (void)( std::declval<T &>( ).subspan( 1 ) ),
70 (
void)( std::declval<std::size_t &>( ) =
71 std::declval<T &>( ).size( ) ),
72 (
void)( std::declval<bool &>( ) =
73 std::declval<T &>( ).empty( ) ),
74 (
void)( *std::declval<T &>( ).data( ) =
75 std::declval<CharT>( ) ) );
79 using remove_prefix_test =
80 decltype( std::declval<T &>( ).remove_prefix( std::size_t{ 1 } ) );
83 DAW_CPP20_CONCEPT has_remove_prefix_v =
84 daw::is_detected_v<remove_prefix_test, T>;
86 template<
typename T,
typename CharT>
87 DAW_CPP20_CONCEPT is_span_like_range_v =
88 daw::is_detected_v<span_like_range_test, T, CharT> and
89 ( writeable_output_details::is_char_sized_character_v<CharT> or
90 writeable_output_details::is_byte_type_v<CharT> );
92 template<
typename T,
typename CharT>
93 using resizable_contiguous_range_test =
94 decltype( (void)( std::declval<T &>( ).resize( std::size_t{ 0 } ) ),
95 (void)( std::declval<T &>( ).size( ) ),
96 (
void)( *std::declval<T &>( ).data( ) ),
97 (
void)( *std::declval<T &>( ).data( ) =
98 std::declval<CharT>( ) ),
99 (
void)( std::declval<T &>( ).push_back(
100 std::declval<CharT>( ) ) ),
101 (
void)(
static_cast<CharT
>(
'a' ) ) );
103 template<
typename Container,
typename CharT>
104 DAW_CPP20_CONCEPT is_resizable_contiguous_range_v =
105 daw::is_detected_v<resizable_contiguous_range_test, Container, CharT>;
107 template<
typename Container,
typename CharT>
108 DAW_CPP20_CONCEPT is_string_like_writable_output_v =
109 ( writeable_output_details::is_char_sized_character_v<CharT> or
110 writeable_output_details::is_byte_type_v<CharT> ) and
111 writeable_output_details::is_resizable_contiguous_range_v<Container,
115 using is_writable_output_iterator_test =
116 decltype( *std::declval<T &>( ) =
'c', ++std::declval<T &>( ) );
119 DAW_CPP20_CONCEPT is_writable_output_iterator_v =
120 not std::is_pointer_v<T> and
121 daw::is_detected_v<is_writable_output_iterator_test, T>;