Skip to content

Commit b0ceeb9

Browse files
committed
Getting rid of no longer needed type detection
1 parent 2678578 commit b0ceeb9

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

lib/inc/sys_string/impl/builder.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ namespace sysstr
161161
{ append_many(m_impl, str, std::char_traits<Char>::length(str)); return *this; }
162162

163163
sys_string_builder_t & append(const sys_string_t<Storage> & str)
164-
{ append_access(typename sys_string_t<Storage>::char_access(str)); return *this; }
164+
{ append_range(typename sys_string_t<Storage>::char_access(str)); return *this; }
165165

166166
sys_string_t<Storage> build() noexcept
167167
{ return util::build<Storage>(m_impl); }
@@ -188,8 +188,8 @@ namespace sysstr
188188
template<has_utf_encoding Char>
189189
static typename impl_type::iterator insert_many(impl_type & impl, typename impl_type::iterator pos, const Char * str, size_t len);
190190

191-
template<class Access>
192-
void append_access(const Access & access);
191+
template<std::ranges::input_range Range>
192+
void append_range(const Range & range);
193193

194194
auto storage_begin() const
195195
{ return std::begin(m_impl); }
@@ -271,20 +271,19 @@ namespace sysstr
271271
}
272272

273273
template<class Storage>
274-
template<class Access>
275-
inline void sys_string_builder_t<Storage>::append_access(const Access & access)
274+
template<std::ranges::input_range Range>
275+
inline void sys_string_builder_t<Storage>::append_range(const Range & range)
276276
{
277-
if constexpr (util::has_contiguous_data<Access>)
277+
static_assert(std::is_same_v<std::ranges::range_value_t<Range>, storage_type>);
278+
279+
if constexpr (std::ranges::contiguous_range<Range>)
278280
{
279-
m_impl.append(access.data(), access.size());
281+
m_impl.append(std::data(range), std::size(range));
280282
}
281283
else
282284
{
283-
for(typename Access::size_type i = 0, count = access.size(); i < count; ++i)
284-
{
285-
auto c = access[i];
285+
for(storage_type c: range)
286286
m_impl.push_back(c);
287-
}
288287
}
289288
}
290289

lib/inc/sys_string/sys_string.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ namespace sysstr
4545

4646
namespace sysstr::util
4747
{
48-
struct char_access_data_detector
49-
{
50-
template<class CharAccess>
51-
auto operator()(const CharAccess * access) noexcept(noexcept(access->data())) -> decltype(access->data());
52-
};
53-
54-
template<class CharAccess>
55-
constexpr bool has_contiguous_data =
56-
std::is_nothrow_invocable_r_v<const typename CharAccess::value_type *,char_access_data_detector, const CharAccess *>;
57-
5848
template<class Storage, class First, class Second>
5949
class addition;
6050

0 commit comments

Comments
 (0)