Change naming convention for template impl of standard class

This commit is contained in:
rexy712 2020-07-28 06:22:33 -07:00
parent c83d2ce686
commit f4aa7f8564
9 changed files with 116 additions and 116 deletions

View File

@ -24,9 +24,9 @@
namespace rexy{
using binary = binary_data<detail::default_allocator<>>;
using binary = basic_binary<detail::default_allocator<>>;
extern template class binary_data<detail::default_allocator<>>;
extern template class basic_binary<detail::default_allocator<>>;
}

View File

@ -61,31 +61,31 @@ namespace rexy{
};
template<class Allocator = detail::default_allocator<>>
class binary_data : public binary_base
class basic_binary : public binary_base
{
public:
using allocator_type = Allocator;
public:
constexpr binary_data(void)noexcept;
constexpr binary_data(rexy::steal<char*> data, size_t size)noexcept;
constexpr binary_data(rexy::steal<char*> data, size_t cap, size_t size)noexcept;
constexpr binary_data(rexy::steal<char*> data)noexcept;
binary_data(const char* data, size_t size)noexcept(noexcept(Allocator::copy(data, size)));
binary_data(const char* data)noexcept(noexcept(Allocator::copy(data, 0)));
binary_data(const char* data, size_t size, size_t cap)noexcept(noexcept(Allocator::copy(data, size)));
explicit binary_data(size_t size)noexcept(noexcept(Allocator::allocate(size)));
binary_data(size_t size, size_t cap)noexcept(noexcept(Allocator::allocate(size)));
constexpr basic_binary(void)noexcept;
constexpr basic_binary(rexy::steal<char*> data, size_t size)noexcept;
constexpr basic_binary(rexy::steal<char*> data, size_t cap, size_t size)noexcept;
constexpr basic_binary(rexy::steal<char*> data)noexcept;
basic_binary(const char* data, size_t size)noexcept(noexcept(Allocator::copy(data, size)));
basic_binary(const char* data)noexcept(noexcept(Allocator::copy(data, 0)));
basic_binary(const char* data, size_t size, size_t cap)noexcept(noexcept(Allocator::copy(data, size)));
explicit basic_binary(size_t size)noexcept(noexcept(Allocator::allocate(size)));
basic_binary(size_t size, size_t cap)noexcept(noexcept(Allocator::allocate(size)));
binary_data(const binary_data& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_cap)));
constexpr binary_data(binary_data&& b)noexcept;
binary_data(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(),b.size())));
basic_binary(const basic_binary& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_cap)));
constexpr basic_binary(basic_binary&& b)noexcept;
basic_binary(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(),b.size())));
~binary_data(void)noexcept(noexcept(Allocator::free(m_data)));
~basic_binary(void)noexcept(noexcept(Allocator::free(m_data)));
binary_data& operator=(const binary_data& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_size)));
constexpr binary_data& operator=(binary_data&& b)noexcept;
binary_data& operator=(const char* c)noexcept(noexcept(Allocator::copy(c, 0)));
binary_data& operator=(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(), b.size())));
basic_binary& operator=(const basic_binary& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_size)));
constexpr basic_binary& operator=(basic_binary&& b)noexcept;
basic_binary& operator=(const char* c)noexcept(noexcept(Allocator::copy(c, 0)));
basic_binary& operator=(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(), b.size())));
void reset(void)
noexcept(noexcept(Allocator::free(m_data)));
@ -98,7 +98,7 @@ namespace rexy{
noexcept(noexcept(Allocator::allocate(0)) &&
noexcept(Allocator::free(nullptr)));
private:
binary_data& _copy_data(const char* data, size_t len)
basic_binary& _copy_data(const char* data, size_t len)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)));
};
@ -115,9 +115,9 @@ namespace rexy{
constexpr size_t size(void)const noexcept;
template<class Alloc>
operator binary_data<Alloc>(void)
noexcept(std::is_nothrow_constructible<binary_data<Alloc>, size_t>::value &&
std::is_nothrow_invocable<detail::string_appender<binary_data<Alloc>>,decltype(*this)>::value);
operator basic_binary<Alloc>(void)
noexcept(std::is_nothrow_constructible<basic_binary<Alloc>, size_t>::value &&
std::is_nothrow_invocable<detail::string_appender<basic_binary<Alloc>>,decltype(*this)>::value);
};
class static_binary : public binary_base

View File

@ -70,84 +70,84 @@ namespace rexy{
}
template<class Allocator>
constexpr binary_data<Allocator>::binary_data(void)noexcept{}
constexpr basic_binary<Allocator>::basic_binary(void)noexcept{}
template<class Allocator>
constexpr binary_data<Allocator>::binary_data(rexy::steal<char*> data)noexcept:
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<char*> data)noexcept:
binary_base(data.value() ? cx::strlen(data.value()) : 0)
{
m_data = data.value();
m_size = m_cap;
}
template<class Allocator>
constexpr binary_data<Allocator>::binary_data(rexy::steal<char*> data, size_t size)noexcept:
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<char*> data, size_t size)noexcept:
binary_base(data.value(), size){}
template<class Allocator>
constexpr binary_data<Allocator>::binary_data(rexy::steal<char*> data, size_t cap, size_t size)noexcept:
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<char*> data, size_t cap, size_t size)noexcept:
binary_base(data.value(), cap, size){}
template<class Allocator>
binary_data<Allocator>::binary_data(const char* data, size_t size)
basic_binary<Allocator>::basic_binary(const char* data, size_t size)
noexcept(noexcept(Allocator::copy(data, size))):
binary_base(reinterpret_cast<char*>(Allocator::copy(data, size)), size){}
template<class Allocator>
binary_data<Allocator>::binary_data(const char* data)
basic_binary<Allocator>::basic_binary(const char* data)
noexcept(noexcept(Allocator::copy(data, 0))):
binary_data(data, cx::strlen(data)){}
basic_binary(data, cx::strlen(data)){}
template<class Allocator>
binary_data<Allocator>::binary_data(const char* data, size_t size, size_t cap)
basic_binary<Allocator>::basic_binary(const char* data, size_t size, size_t cap)
noexcept(noexcept(Allocator::copy(data, size))):
binary_base(reinterpret_cast<char*>(Allocator::copy(data, size)), size, cap){}
template<class Allocator>
binary_data<Allocator>::binary_data(size_t size)
basic_binary<Allocator>::basic_binary(size_t size)
noexcept(noexcept(Allocator::allocate(size))):
binary_base(reinterpret_cast<char*>(Allocator::allocate(size)), size){}
template<class Allocator>
binary_data<Allocator>::binary_data(size_t size, size_t cap)
basic_binary<Allocator>::basic_binary(size_t size, size_t cap)
noexcept(noexcept(Allocator::allocate(size))):
binary_base(reinterpret_cast<char*>(size ? Allocator::allocate(size) : nullptr), size, cap){}
template<class Allocator>
binary_data<Allocator>::binary_data(const binary_data& b)
basic_binary<Allocator>::basic_binary(const basic_binary& b)
noexcept(noexcept(Allocator::copy(b.m_data, b.m_cap))):
binary_base(reinterpret_cast<char*>(b.m_size ? Allocator::copy(b.m_data, b.m_size) : nullptr), b.m_size, b.m_size){}
template<class Allocator>
constexpr binary_data<Allocator>::binary_data(binary_data&& b)noexcept:
constexpr basic_binary<Allocator>::basic_binary(basic_binary&& b)noexcept:
binary_base(cx::exchange(b.m_data, nullptr), b.m_size, b.m_cap){}
template<class Allocator>
binary_data<Allocator>::binary_data(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(),b.size()))):
basic_binary<Allocator>::basic_binary(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(),b.size()))):
binary_base(reinterpret_cast<char*>(b.size() ? Allocator::copy(b.get(), b.size()) : nullptr), b.size(), b.size()){}
template<class Allocator>
binary_data<Allocator>::~binary_data(void)
basic_binary<Allocator>::~basic_binary(void)
noexcept(noexcept(Allocator::free(m_data)))
{
Allocator::free(m_data);
}
template<class Allocator>
binary_data<Allocator>& binary_data<Allocator>::operator=(const binary_data& b)
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const basic_binary& b)
noexcept(noexcept(Allocator::copy(b.m_data, b.m_size)))
{
return _copy_data(b.get(), b.size());
}
template<class Allocator>
constexpr binary_data<Allocator>& binary_data<Allocator>::operator=(binary_data&& b)noexcept{
constexpr basic_binary<Allocator>& basic_binary<Allocator>::operator=(basic_binary&& b)noexcept{
m_size = b.m_size;
m_cap = b.m_cap;
cx::swap(m_data, b.m_data);
return *this;
}
template<class Allocator>
binary_data<Allocator>& binary_data<Allocator>::operator=(const char* c)
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const char* c)
noexcept(noexcept(Allocator::copy(c, 0)))
{
return _copy_data(c, strlen(c));
}
template<class Allocator>
binary_data<Allocator>& binary_data<Allocator>::operator=(const binary_base& b)
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const binary_base& b)
noexcept(noexcept(Allocator::copy(b.get(), b.size())))
{
return _copy_data(b.get(), b.size());
}
template<class Allocator>
void binary_data<Allocator>::reset(void)
void basic_binary<Allocator>::reset(void)
noexcept(noexcept(Allocator::free(m_data)))
{
Allocator::free(m_data);
@ -155,7 +155,7 @@ namespace rexy{
m_cap = m_size = 0;
}
template<class Allocator>
void binary_data<Allocator>::reset(char* val, size_t cap, size_t size)
void basic_binary<Allocator>::reset(char* val, size_t cap, size_t size)
noexcept(noexcept(Allocator::free(m_data)))
{
Allocator::free(m_data);
@ -164,13 +164,13 @@ namespace rexy{
m_size = size;
}
template<class Allocator>
bool binary_data<Allocator>::resize(size_t newsize)
bool basic_binary<Allocator>::resize(size_t newsize)
noexcept(noexcept(Allocator::allocate(0)) &&
noexcept(Allocator::free(nullptr)))
{
if(newsize < m_cap)
return false;
binary_data<allocator_type> tmp(newsize);
basic_binary<allocator_type> tmp(newsize);
if(!tmp)
return false;
memcpy(STOP_STRICT_ALIAS_WARNING(tmp).m_data, m_data, m_size);
@ -179,7 +179,7 @@ namespace rexy{
return true;
}
template<class Allocator>
void binary_data<Allocator>::append(const char* data, size_t len)
void basic_binary<Allocator>::append(const char* data, size_t len)
noexcept(noexcept(Allocator::allocate(0)) &&
noexcept(Allocator::free(nullptr)))
{
@ -189,18 +189,18 @@ namespace rexy{
m_size += len;
}
template<class Allocator>
binary_data<Allocator>& binary_data<Allocator>::_copy_data(const char* data, size_t len)
basic_binary<Allocator>& basic_binary<Allocator>::_copy_data(const char* data, size_t len)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)))
{
if(!len)
return (*this = binary_data(rexy::steal<char*>(nullptr), 0, 0));
return (*this = basic_binary(rexy::steal<char*>(nullptr), 0, 0));
if(len <= m_size){
m_size = len;
memcpy(m_data, data, len);
return *this;
}
return (*this = binary_data(data, len));
return (*this = basic_binary(data, len));
}
constexpr static_binary::static_binary(const char* str, size_t len)noexcept:
@ -238,14 +238,14 @@ namespace rexy{
template<class Left, class Right>
template<class Alloc>
binary_cat_expr<Left,Right>::operator binary_data<Alloc>(void)
noexcept(std::is_nothrow_constructible<binary_data<Alloc>, size_t>::value &&
std::is_nothrow_invocable<detail::string_appender<binary_data<Alloc>>,decltype(*this)>::value)
binary_cat_expr<Left,Right>::operator basic_binary<Alloc>(void)
noexcept(std::is_nothrow_constructible<basic_binary<Alloc>, size_t>::value &&
std::is_nothrow_invocable<detail::string_appender<basic_binary<Alloc>>,decltype(*this)>::value)
{
auto sz = size();
binary_data<Alloc> ret(sz);
basic_binary<Alloc> ret(sz);
detail::string_appender<binary_data<Alloc>> append(ret);
detail::string_appender<basic_binary<Alloc>> append(ret);
append(*this);
return ret;

View File

@ -33,7 +33,7 @@ namespace rexy{
return s;
}
template<class Al, class Str, detail::enable_if_concrete_string<Str> = 0, std::enable_if_t<std::is_same<std::decay_t<Al>,typename Str::allocator_type>::value,int> = 0>
auto binary_to_string(binary_data<Al>&& b)noexcept{
auto binary_to_string(basic_binary<Al>&& b)noexcept{
return Str(rexy::steal(b.release()), b.size());
}
template<class Bin, detail::enable_if_binary<Bin> = 0>
@ -46,7 +46,7 @@ namespace rexy{
return b;
}
template<class Al, class Bin, detail::enable_if_binary<Bin> = 0, std::enable_if_t<std::is_same<std::decay_t<Al>,typename Bin::allocator_type>::value,int> = 0>
auto string_to_binary(string_intermediary<Al>&& s)noexcept{
auto string_to_binary(basic_string<Al>&& s)noexcept{
return Bin(rexy::steal(s.release()), s.length());
}

View File

@ -25,9 +25,9 @@
namespace rexy{
//new allocated string
using string = string_intermediary<detail::default_allocator<>>;
using string = basic_string<detail::default_allocator<>>;
extern template class string_intermediary<detail::default_allocator<>>;
extern template class basic_string<detail::default_allocator<>>;
}

View File

@ -77,46 +77,46 @@ namespace rexy{
//Supplies all functions that string_base can't implement
template<class Allocator>
class string_intermediary : public string_base
class basic_string : public string_base
{
public:
using allocator_type = Allocator;
private:
string_intermediary& _copy_string(const char* s, size_t len)
basic_string& _copy_string(const char* s, size_t len)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)));
public:
constexpr string_intermediary(void)noexcept;
constexpr string_intermediary(rexy::steal<char*> data, size_t len)noexcept;
constexpr string_intermediary(rexy::steal<char*> data, size_t len, size_t cap)noexcept;
constexpr string_intermediary(rexy::steal<char*> data)noexcept;
string_intermediary(const char* data, size_t len)noexcept(noexcept(Allocator::copy(data,len)));
string_intermediary(const char* data)noexcept(noexcept(Allocator::copy(data, m_cap)));
explicit string_intermediary(size_t len)noexcept(noexcept(Allocator::allocate(len)));
string_intermediary(size_t len, size_t cap)noexcept(noexcept(Allocator::allocate(len)));
constexpr basic_string(void)noexcept;
constexpr basic_string(rexy::steal<char*> data, size_t len)noexcept;
constexpr basic_string(rexy::steal<char*> data, size_t len, size_t cap)noexcept;
constexpr basic_string(rexy::steal<char*> data)noexcept;
basic_string(const char* data, size_t len)noexcept(noexcept(Allocator::copy(data,len)));
basic_string(const char* data)noexcept(noexcept(Allocator::copy(data, m_cap)));
explicit basic_string(size_t len)noexcept(noexcept(Allocator::allocate(len)));
basic_string(size_t len, size_t cap)noexcept(noexcept(Allocator::allocate(len)));
//normal copy and move ctors
string_intermediary(const string_intermediary& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_length)));
constexpr string_intermediary(string_intermediary&& s)noexcept(noexcept(cx::exchange(s.m_data, nullptr)));
basic_string(const basic_string& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_length)));
constexpr basic_string(basic_string&& s)noexcept(noexcept(cx::exchange(s.m_data, nullptr)));
string_intermediary(const string_base& b)noexcept(noexcept(Allocator::copy(b.get(), b.length())));
basic_string(const string_base& b)noexcept(noexcept(Allocator::copy(b.get(), b.length())));
//dtor
~string_intermediary(void)noexcept(noexcept(Allocator::free(m_data)));
~basic_string(void)noexcept(noexcept(Allocator::free(m_data)));
string_intermediary& operator=(const string_intermediary& s)
basic_string& operator=(const basic_string& s)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)));
constexpr string_intermediary& operator=(string_intermediary&& s)noexcept;
constexpr basic_string& operator=(basic_string&& s)noexcept;
//Copy from c string
string_intermediary& operator=(const char* c)
basic_string& operator=(const char* c)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)));
//Copy from other string_base
string_intermediary& operator=(const string_base& s)
basic_string& operator=(const string_base& s)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)));
@ -151,9 +151,9 @@ namespace rexy{
constexpr size_t length(void)const noexcept;
template<class Alloc>
operator string_intermediary<Alloc>(void)
noexcept(std::is_nothrow_constructible<string_intermediary<Alloc>, size_t>::value &&
std::is_nothrow_invocable<detail::string_appender<string_intermediary<Alloc>>,decltype(*this)>::value);
operator basic_string<Alloc>(void)
noexcept(std::is_nothrow_constructible<basic_string<Alloc>, size_t>::value &&
std::is_nothrow_invocable<detail::string_appender<basic_string<Alloc>>,decltype(*this)>::value);
};
template<class Left, class Right>
string_cat_expr(Left&&,Right&&) -> string_cat_expr<Left&&,Right&&>;

View File

@ -31,29 +31,29 @@
namespace rexy{
template<class Allocator>
constexpr string_intermediary<Allocator>::string_intermediary(void)noexcept{}
constexpr basic_string<Allocator>::basic_string(void)noexcept{}
template<class Allocator>
constexpr string_intermediary<Allocator>::string_intermediary(rexy::steal<char*> data)noexcept:
constexpr basic_string<Allocator>::basic_string(rexy::steal<char*> data)noexcept:
string_base(data.value() ? cx::strlen(data.value()) : 0)
{
m_data = data.value();
m_length = m_cap;
}
template<class Allocator>
constexpr string_intermediary<Allocator>::string_intermediary(rexy::steal<char*> data, size_t len)noexcept:
constexpr basic_string<Allocator>::basic_string(rexy::steal<char*> data, size_t len)noexcept:
string_base(data.value(), len, len){}
template<class Allocator>
constexpr string_intermediary<Allocator>::string_intermediary(rexy::steal<char*> data, size_t len, size_t cap)noexcept:
constexpr basic_string<Allocator>::basic_string(rexy::steal<char*> data, size_t len, size_t cap)noexcept:
string_base(data.value(), len, cap){}
template<class Allocator>
string_intermediary<Allocator>::string_intermediary(const char* data, size_t len)
basic_string<Allocator>::basic_string(const char* data, size_t len)
noexcept(noexcept(Allocator::copy(data,len))):
string_base(reinterpret_cast<char*>(len ? Allocator::copy(data, len+1) : nullptr), len, len)
{
m_data[len] = 0;
}
template<class Allocator>
string_intermediary<Allocator>::string_intermediary(const char* data)
basic_string<Allocator>::basic_string(const char* data)
noexcept(noexcept(Allocator::copy(data, m_cap))):
string_base(data ? strlen(data) : 0)
{
@ -63,14 +63,14 @@ namespace rexy{
}
}
template<class Allocator>
string_intermediary<Allocator>::string_intermediary(size_t len)
basic_string<Allocator>::basic_string(size_t len)
noexcept(noexcept(Allocator::allocate(len))):
string_base(reinterpret_cast<char*>(len ? Allocator::allocate(len+1) : nullptr), len)
{
m_data[len] = 0;
}
template<class Allocator>
string_intermediary<Allocator>::string_intermediary(size_t len, size_t cap)
basic_string<Allocator>::basic_string(size_t len, size_t cap)
noexcept(noexcept(Allocator::allocate(len))):
string_base(reinterpret_cast<char*>(len ? Allocator::allocate(len+1) : nullptr), len, cap)
{
@ -79,29 +79,29 @@ namespace rexy{
//normal copy and move ctors
template<class Allocator>
string_intermediary<Allocator>::string_intermediary(const string_intermediary& b)
basic_string<Allocator>::basic_string(const basic_string& b)
noexcept(noexcept(Allocator::copy(b.m_data, b.m_length))):
string_base(reinterpret_cast<char*>(b.m_length ? Allocator::copy(b.m_data, b.m_length+1) : nullptr), b.m_length, b.m_length){}
template<class Allocator>
constexpr string_intermediary<Allocator>::string_intermediary(string_intermediary&& s)
constexpr basic_string<Allocator>::basic_string(basic_string&& s)
noexcept(noexcept(cx::exchange(s.m_data, nullptr))):
string_base(cx::exchange(s.m_data, nullptr), s.m_length, s.m_cap){}
template<class Allocator>
string_intermediary<Allocator>::string_intermediary(const string_base& b)
basic_string<Allocator>::basic_string(const string_base& b)
noexcept(noexcept(Allocator::copy(b.get(), b.length()))):
string_base(reinterpret_cast<char*>(b.length() ? Allocator::copy(b.get(), b.length()+1) : nullptr), b.length(), b.length()){}
//dtor
template<class Allocator>
string_intermediary<Allocator>::~string_intermediary(void)
basic_string<Allocator>::~basic_string(void)
noexcept(noexcept(Allocator::free(m_data)))
{
Allocator::free(m_data);
}
template<class Allocator>
string_intermediary<Allocator>& string_intermediary<Allocator>::operator=(const string_intermediary& s)
basic_string<Allocator>& basic_string<Allocator>::operator=(const basic_string& s)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)))
{
@ -110,11 +110,11 @@ namespace rexy{
m_length = s.m_length;
return *this;
}
string_intermediary tmp(s);
basic_string tmp(s);
return (*this = std::move(tmp));
}
template<class Allocator>
constexpr string_intermediary<Allocator>& string_intermediary<Allocator>::operator=(string_intermediary&& s)noexcept{
constexpr basic_string<Allocator>& basic_string<Allocator>::operator=(basic_string&& s)noexcept{
cx::swap(m_data, s.m_data);
m_length = s.m_length;
m_cap = s.m_cap;
@ -122,7 +122,7 @@ namespace rexy{
}
//Copy from c string
template<class Allocator>
string_intermediary<Allocator>& string_intermediary<Allocator>::operator=(const char* c)
basic_string<Allocator>& basic_string<Allocator>::operator=(const char* c)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)))
{
@ -130,7 +130,7 @@ namespace rexy{
}
//Copy from other string_base
template<class Allocator>
string_intermediary<Allocator>& string_intermediary<Allocator>::operator=(const string_base& s)
basic_string<Allocator>& basic_string<Allocator>::operator=(const string_base& s)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)))
{
@ -139,7 +139,7 @@ namespace rexy{
//Replace managed pointer. Frees existing value
template<class Allocator>
void string_intermediary<Allocator>::reset(char* val)
void basic_string<Allocator>::reset(char* val)
noexcept(noexcept(Allocator::free(m_data)))
{
Allocator::free(m_data);
@ -148,7 +148,7 @@ namespace rexy{
m_cap = m_length;
}
template<class Allocator>
void string_intermediary<Allocator>::reset(char* val, size_t len)
void basic_string<Allocator>::reset(char* val, size_t len)
noexcept(noexcept(Allocator::free(m_data)))
{
Allocator::free(m_data);
@ -157,16 +157,16 @@ namespace rexy{
m_cap = len;
}
template<class Allocator>
bool string_intermediary<Allocator>::resize(size_t newsize)
bool basic_string<Allocator>::resize(size_t newsize)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)))
{
if(newsize < m_cap)
return false;
return (*this = string_intermediary(m_data, newsize));
return (*this = basic_string(m_data, newsize));
}
template<class Allocator>
void string_intermediary<Allocator>::append(const char* data, size_t len)
void basic_string<Allocator>::append(const char* data, size_t len)
noexcept(noexcept(Allocator::allocate(0)) &&
noexcept(Allocator::free(nullptr)))
{
@ -175,19 +175,19 @@ namespace rexy{
m_length += len;
m_data[m_length] = 0;
}else if(!m_data){
*this = string_intermediary(len, len);
*this = basic_string(len, len);
memcpy(m_data, data, len);
m_data[len] = 0;
}else{
auto newsize = cx::max(m_length+len, m_cap*2);
string_intermediary tmp(newsize);
basic_string tmp(newsize);
tmp.append(m_data, m_length);
tmp.append(data, len);
*this = std::move(tmp);
}
}
template<class Allocator>
void string_intermediary<Allocator>::append(const char* data)
void basic_string<Allocator>::append(const char* data)
noexcept(noexcept(Allocator::allocate(0)) &&
noexcept(Allocator::free(nullptr)))
{
@ -195,7 +195,7 @@ namespace rexy{
append(data, strlen(data));
}
template<class Allocator>
void string_intermediary<Allocator>::append(const string_base& s)
void basic_string<Allocator>::append(const string_base& s)
noexcept(noexcept(Allocator::allocate(0)) &&
noexcept(Allocator::free(nullptr)))
{
@ -203,19 +203,19 @@ namespace rexy{
}
template<class Allocator>
string_intermediary<Allocator>& string_intermediary<Allocator>::_copy_string(const char* s, size_t len)
basic_string<Allocator>& basic_string<Allocator>::_copy_string(const char* s, size_t len)
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
noexcept(Allocator::free(nullptr)))
{
if(!len)
return (*this = string_intermediary(rexy::steal<char*>(nullptr), 0, 0));
return (*this = basic_string(rexy::steal<char*>(nullptr), 0, 0));
if(len <= m_length){
m_length = len;
memcpy(m_data, s, len);
m_data[len] = 0;
return *this;
}
return (*this = string_intermediary(s, len));
return (*this = basic_string(s, len));
}
@ -225,13 +225,13 @@ namespace rexy{
}
template<class Left, class Right>
template<class Alloc>
string_cat_expr<Left,Right>::operator string_intermediary<Alloc>(void)
noexcept(std::is_nothrow_constructible<string_intermediary<Alloc>, size_t>::value &&
std::is_nothrow_invocable<detail::string_appender<string_intermediary<Alloc>>,decltype(*this)>::value)
string_cat_expr<Left,Right>::operator basic_string<Alloc>(void)
noexcept(std::is_nothrow_constructible<basic_string<Alloc>, size_t>::value &&
std::is_nothrow_invocable<detail::string_appender<basic_string<Alloc>>,decltype(*this)>::value)
{
size_t len = length();
string_intermediary<Alloc> ret(len);
detail::string_appender<string_intermediary<Alloc>> append(ret);
basic_string<Alloc> ret(len);
detail::string_appender<basic_string<Alloc>> append(ret);
append(*this);
return ret;
}

View File

@ -21,6 +21,6 @@
namespace rexy{
template class binary_data<detail::default_allocator<>>;
template class basic_binary<detail::default_allocator<>>;
}

View File

@ -21,6 +21,6 @@
namespace rexy{
template class string_intermediary<detail::default_allocator<>>;
template class basic_string<detail::default_allocator<>>;
}