Change size_t to std::size_t
This commit is contained in:
parent
61987d937b
commit
5ce29908df
@ -19,8 +19,8 @@
|
||||
#ifndef REXY_ALGORITHM_TPP
|
||||
#define REXY_ALGORITHM_TPP
|
||||
|
||||
#include <cstdint> //SIZE_MAX
|
||||
#include <cstdlib> //size_t
|
||||
#include <cstddef> //size_t
|
||||
#include <limits> //numeric_limits
|
||||
|
||||
namespace rexy{
|
||||
|
||||
@ -41,14 +41,14 @@ namespace rexy{
|
||||
//Requires Iterators to be LegacyRandomAccessIterators
|
||||
template<class HIter, class NIter>
|
||||
constexpr HIter two_way_search(HIter hstart, HIter hend, NIter nstart, NIter nend){
|
||||
size_t j = 0;
|
||||
size_t i = 0;
|
||||
size_t nlen = nend - nstart;
|
||||
size_t hlen = hend - hstart;
|
||||
std::size_t j = 0;
|
||||
std::size_t i = 0;
|
||||
std::size_t nlen = nend - nstart;
|
||||
std::size_t hlen = hend - hstart;
|
||||
auto [suffix, period] = detail::critical_factorization(nstart, nend);
|
||||
|
||||
if(detail::iter_compare(nstart, nstart + period, suffix)){
|
||||
size_t memory = SIZE_MAX;
|
||||
std::size_t memory = std::numeric_limits<std::size_t>::max();
|
||||
while(j <= hlen - nlen){
|
||||
i = max(suffix, memory) + 1;
|
||||
//right side
|
||||
@ -68,7 +68,7 @@ namespace rexy{
|
||||
memory = nlen - period - 1;
|
||||
}else{
|
||||
j += (i - suffix);
|
||||
memory = SIZE_MAX;
|
||||
memory = std::numeric_limits<std::size_t>::max();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
@ -83,10 +83,10 @@ namespace rexy{
|
||||
if(i >= nlen){
|
||||
i = suffix;
|
||||
//left side
|
||||
while(i != SIZE_MAX && nstart[i] == hstart[i + j]){
|
||||
while(i != std::numeric_limits<std::size_t>::max() && nstart[i] == hstart[i + j]){
|
||||
--i;
|
||||
}
|
||||
if(i == SIZE_MAX){
|
||||
if(i == std::numeric_limits<std::size_t>::max()){
|
||||
return hstart + j;
|
||||
}
|
||||
j += period;
|
||||
|
||||
@ -51,7 +51,7 @@ namespace rexy{
|
||||
using void_pointer = void*;
|
||||
using const_void_pointer = const void*;
|
||||
using value_type = T;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using is_always_equal = std::true_type;
|
||||
using propagate_on_container_copy_assignment = std::false_type;
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include "allocator.hpp"
|
||||
#include "detail/hasallocator.hpp"
|
||||
#include <cstdlib> //size_t, ptrdiff_t
|
||||
#include <cstddef> //size_t, ptrdiff_t
|
||||
#include <iterator> //reverse_iterator
|
||||
|
||||
#include "compat/standard.hpp"
|
||||
@ -33,7 +33,7 @@ namespace rexy{
|
||||
{
|
||||
public:
|
||||
using value_type = T;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = T*;
|
||||
using const_pointer = const T*;
|
||||
|
||||
@ -27,12 +27,12 @@
|
||||
|
||||
namespace rexy::cx{
|
||||
|
||||
template<class T, size_t N>
|
||||
template<class T, std::size_t N>
|
||||
class array
|
||||
{
|
||||
public:
|
||||
using value_type = T;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using reference = T&;
|
||||
using const_reference = const T&;
|
||||
@ -125,7 +125,7 @@ namespace rexy::cx{
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
template<std::size_t N>
|
||||
class array<bool,N> : public detail::bool_specialize_base
|
||||
{
|
||||
public:
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
namespace rexy::cx{
|
||||
|
||||
template<size_t N>
|
||||
template<std::size_t N>
|
||||
struct hash<rexy::cx::string<N>> : public string_hash<rexy::cx::string<N>>{};
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ namespace rexy::cx::detail{
|
||||
class bool_specialize_base
|
||||
{
|
||||
protected:
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
static constexpr size_type bits_per_byte = CHAR_BIT;
|
||||
|
||||
@ -91,10 +91,10 @@ namespace rexy::cx::detail{
|
||||
constexpr booleans& operator=(const booleans&)noexcept = default;
|
||||
constexpr booleans& operator=(booleans&&)noexcept = default;
|
||||
|
||||
constexpr boolean operator[](size_t i){
|
||||
constexpr boolean operator[](std::size_t i){
|
||||
return boolean{m_value, i};
|
||||
}
|
||||
constexpr boolean operator[](size_t i)const{
|
||||
constexpr boolean operator[](std::size_t i)const{
|
||||
return boolean{const_cast<uchar&>(m_value), i};
|
||||
}
|
||||
constexpr uchar& data(void){
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
#include "../hash.hpp"
|
||||
|
||||
#include <climits> //CHAR_BIT
|
||||
#include <cstddef> //size_t, ptrdiff_t
|
||||
#include <cstddef> //std::size_t, ptrdiff_t
|
||||
#include <type_traits> //decay
|
||||
#include <initializer_list>
|
||||
|
||||
@ -42,14 +42,14 @@ namespace rexy::cx{
|
||||
template<class Key, class Value>
|
||||
element(Key,Value) -> element<Key,Value>;
|
||||
|
||||
template<class Key, class Value, size_t N, class Hash = hash<Key>>
|
||||
template<class Key, class Value, std::size_t N, class Hash = hash<Key>>
|
||||
class hashmap
|
||||
{
|
||||
public:
|
||||
using key_type = Key;
|
||||
using mapped_type = Value;
|
||||
using value_type = element<Key,Value>;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using hasher = Hash;
|
||||
using reference = mapped_type&;
|
||||
@ -72,7 +72,7 @@ namespace rexy::cx{
|
||||
noexcept(std::is_nothrow_default_constructible<value_type>::value &&
|
||||
std::is_nothrow_copy_constructible<value_type>::value &&
|
||||
std::is_nothrow_move_assignable<mapped_type>::value &&
|
||||
std::is_nothrow_invocable<Hash,Key,size_t>::value);
|
||||
std::is_nothrow_invocable<Hash,Key,std::size_t>::value);
|
||||
|
||||
//no key checks. give a correct key or get a random answer :)
|
||||
template<class U, class UHash = hash<std::decay_t<U>>>
|
||||
|
||||
@ -23,12 +23,12 @@
|
||||
|
||||
namespace rexy::cx{
|
||||
|
||||
template<class Key, class Value, size_t N, class Hash>
|
||||
template<class Key, class Value, std::size_t N, class Hash>
|
||||
constexpr hashmap<Key,Value,N,Hash>::hashmap(const value_type(&elements)[N])
|
||||
noexcept(std::is_nothrow_default_constructible<value_type>::value &&
|
||||
std::is_nothrow_copy_constructible<value_type>::value &&
|
||||
std::is_nothrow_move_assignable<mapped_type>::value &&
|
||||
std::is_nothrow_invocable<Hash,Key,size_t>::value)
|
||||
std::is_nothrow_invocable<Hash,Key,std::size_t>::value)
|
||||
{
|
||||
array<vector<value_type,N>,N> buckets;
|
||||
array<size_type,N> key_hashes; //full hash values for keys to verify good index values
|
||||
@ -101,7 +101,7 @@ namespace rexy::cx{
|
||||
}
|
||||
|
||||
//no key checks. give a correct key or get a random answer :)
|
||||
template<class Key, class Value, size_t N, class Hash>
|
||||
template<class Key, class Value, std::size_t N, class Hash>
|
||||
template<class U, class UHash>
|
||||
constexpr auto hashmap<Key,Value,N,Hash>::operator[](U&& key)noexcept -> reference{
|
||||
auto d = m_g[UHash{}(std::forward<U>(key), 0) % max_size];
|
||||
@ -109,7 +109,7 @@ namespace rexy::cx{
|
||||
return m_elements[d & ~single_bucket_bit].value;
|
||||
return m_elements[UHash{}(std::forward<U>(key), d) % max_size].value;
|
||||
}
|
||||
template<class Key, class Value, size_t N, class Hash>
|
||||
template<class Key, class Value, std::size_t N, class Hash>
|
||||
template<class U, class UHash>
|
||||
constexpr auto hashmap<Key,Value,N,Hash>::operator[](U&& key)const noexcept -> const_reference{
|
||||
auto d = m_g[UHash{}(std::forward<U>(key), 0) % max_size];
|
||||
@ -118,7 +118,7 @@ namespace rexy::cx{
|
||||
return m_elements[UHash{}(std::forward<U>(key), d) % max_size].value;
|
||||
}
|
||||
|
||||
template<class Key, class Value, size_t N, class Hash>
|
||||
template<class Key, class Value, std::size_t N, class Hash>
|
||||
template<class U, class UHash>
|
||||
constexpr bool hashmap<Key,Value,N,Hash>::contains(U&& key)const noexcept{
|
||||
const auto hashval = UHash{}(std::forward<U>(key), 0);
|
||||
@ -129,7 +129,7 @@ namespace rexy::cx{
|
||||
return m_elements[UHash{}(std::forward<U>(key), d) % max_size].key == std::forward<U>(key);
|
||||
}
|
||||
|
||||
template<class Key, class Value, size_t N, class Hash = hash<Key>>
|
||||
template<class Key, class Value, std::size_t N, class Hash = hash<Key>>
|
||||
constexpr auto make_hashmap(const typename hashmap<Key,Value,N,Hash>::value_type(&list)[N]){
|
||||
return hashmap<Key,Value,N,Hash>(list);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace rexy::cx{
|
||||
|
||||
namespace rexy::cx{
|
||||
|
||||
template<size_t N, class Char = char>
|
||||
template<std::size_t N, class Char = char>
|
||||
class string
|
||||
{
|
||||
public:
|
||||
|
||||
@ -30,12 +30,12 @@
|
||||
|
||||
namespace rexy::cx{
|
||||
|
||||
template<class T, size_t N>
|
||||
template<class T, std::size_t N>
|
||||
class vector
|
||||
{
|
||||
public:
|
||||
using value_type = T;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using iterator = T*;
|
||||
using const_iterator = const T*;
|
||||
@ -244,7 +244,7 @@ namespace rexy::cx{
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t N>
|
||||
template<std::size_t N>
|
||||
class vector<bool,N> : public detail::bool_specialize_base
|
||||
{
|
||||
public:
|
||||
|
||||
@ -46,7 +46,7 @@ namespace rexy{
|
||||
constexpr operator value_type(void);
|
||||
|
||||
private:
|
||||
template<size_t... Is>
|
||||
template<std::size_t... Is>
|
||||
constexpr value_type get_value_(std::index_sequence<Is...>);
|
||||
};
|
||||
|
||||
@ -70,7 +70,7 @@ namespace rexy{
|
||||
constexpr operator ret_t(void);
|
||||
|
||||
private:
|
||||
template<size_t... Is>
|
||||
template<std::size_t... Is>
|
||||
constexpr decltype(auto) get_value_(std::index_sequence<Is...>);
|
||||
};
|
||||
|
||||
@ -87,7 +87,7 @@ namespace rexy{
|
||||
return get_value_(std::make_index_sequence<sizeof...(Args)>());
|
||||
}
|
||||
template<class T, class... Args>
|
||||
template<size_t... Is>
|
||||
template<std::size_t... Is>
|
||||
constexpr auto deferred<T,Args...>::get_value_(std::index_sequence<Is...>) -> value_type{
|
||||
return T{std::forward<std::tuple_element_t<Is,decltype(m_args)>>(std::get<Is>(m_args))...};
|
||||
}
|
||||
@ -112,7 +112,7 @@ namespace rexy{
|
||||
return get_value_(std::make_index_sequence<sizeof...(Args)>());
|
||||
}
|
||||
template<class Fn, class... Args>
|
||||
template<size_t... Is>
|
||||
template<std::size_t... Is>
|
||||
constexpr decltype(auto) deferred_function<Fn,Args...>::get_value_(std::index_sequence<Is...>){
|
||||
return std::forward<Fn>(m_fn)(std::forward<std::tuple_element_t<Is,decltype(m_args)>>(std::get<Is>(m_args))...);
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
#include <functional> //less, greater
|
||||
#include <utility> //pair
|
||||
#include <iterator> //iterator_traits
|
||||
#include <cstdlib> //size_t
|
||||
#include <cstddef> //size_t
|
||||
|
||||
namespace rexy::detail{
|
||||
|
||||
@ -51,12 +51,12 @@ namespace rexy::detail{
|
||||
return left;
|
||||
}
|
||||
template<class Iter, class Op>
|
||||
constexpr std::pair<size_t,size_t> max_suffix(const Iter& needle, size_t nlen, const Op& op = Op()){
|
||||
constexpr std::pair<std::size_t,size_t> max_suffix(const Iter& needle, std::size_t nlen, const Op& op = Op()){
|
||||
using value_type = typename std::iterator_traits<Iter>::value_type;
|
||||
size_t max_suffix = -1;
|
||||
size_t j = 0;
|
||||
size_t k = 1;
|
||||
size_t period = 1;
|
||||
std::size_t max_suffix = -1;
|
||||
std::size_t j = 0;
|
||||
std::size_t k = 1;
|
||||
std::size_t period = 1;
|
||||
value_type a;
|
||||
value_type b;
|
||||
|
||||
@ -82,7 +82,7 @@ namespace rexy::detail{
|
||||
return {max_suffix, period};
|
||||
}
|
||||
template<class Iter>
|
||||
constexpr std::pair<size_t,size_t> critical_factorization(const Iter& nstart, const Iter& nend){
|
||||
constexpr std::pair<std::size_t,size_t> critical_factorization(const Iter& nstart, const Iter& nend){
|
||||
auto msuffix = max_suffix(nstart, nend - nstart, std::less{});
|
||||
auto msuffix_rev = max_suffix(nstart, nend - nstart, std::greater{});
|
||||
if(msuffix.first < msuffix_rev.first){
|
||||
@ -91,8 +91,8 @@ namespace rexy::detail{
|
||||
return msuffix;
|
||||
}
|
||||
template<class Iter>
|
||||
constexpr bool iter_compare(const Iter& left, const Iter& right, size_t length){
|
||||
for(size_t i = 0;i < length;++i){
|
||||
constexpr bool iter_compare(const Iter& left, const Iter& right, std::size_t length){
|
||||
for(std::size_t i = 0;i < length;++i){
|
||||
if(left[i] != right[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#ifndef REXY_DETAIL_FORMAT_FORMATTER_HPP
|
||||
#define REXY_DETAIL_FORMAT_FORMATTER_HPP
|
||||
|
||||
#include <cstddef> //size_t, nullptr_t
|
||||
#include <cstddef> //std::size_t, nullptr_t
|
||||
#include <variant> //monostate
|
||||
#include <locale> //locale
|
||||
#include <type_traits> //remove_cvref
|
||||
|
||||
@ -54,9 +54,9 @@ namespace rexy{
|
||||
|
||||
void reset(FILE* fp = nullptr)noexcept;
|
||||
FILE* release(void)noexcept;
|
||||
size_t length(void)noexcept;
|
||||
size_t position(void)const noexcept;
|
||||
void rewind(size_t pos = 0)noexcept;
|
||||
std::size_t length(void)noexcept;
|
||||
std::size_t position(void)const noexcept;
|
||||
void rewind(std::size_t pos = 0)noexcept;
|
||||
|
||||
operator FILE*(void)noexcept;
|
||||
operator const FILE*(void)const noexcept;
|
||||
@ -64,13 +64,13 @@ namespace rexy{
|
||||
const FILE* get(void)const noexcept;
|
||||
operator bool(void)const noexcept;
|
||||
|
||||
size_t read(char* dest, size_t bytes)noexcept;
|
||||
rexy::string read(size_t bytes)noexcept;
|
||||
rexy::string readln(size_t max = 0)noexcept;
|
||||
rexy::buffer<char> read_bin(size_t bytes)noexcept(std::is_nothrow_constructible<rexy::buffer<char>, char*, size_t>::value);
|
||||
std::size_t read(char* dest, std::size_t bytes)noexcept;
|
||||
rexy::string read(std::size_t bytes)noexcept;
|
||||
rexy::string readln(std::size_t max = 0)noexcept;
|
||||
rexy::buffer<char> read_bin(std::size_t bytes)noexcept(std::is_nothrow_constructible<rexy::buffer<char>, char*, std::size_t>::value);
|
||||
|
||||
size_t write(const char* c, size_t bytes)noexcept;
|
||||
size_t write(const rexy::string_base<char>& s)noexcept;
|
||||
std::size_t write(const char* c, std::size_t bytes)noexcept;
|
||||
std::size_t write(const rexy::string_base<char>& s)noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -26,11 +26,11 @@ namespace rexy{
|
||||
|
||||
template<class T>
|
||||
struct hash{
|
||||
constexpr size_t operator()(const T& t, size_t salt = 0)const noexcept{
|
||||
constexpr size_t bytes = sizeof(size_t);
|
||||
size_t val = static_cast<size_t>(t);
|
||||
size_t hash = 5381 + salt; //magic hash number
|
||||
for(size_t i = 0;i < bytes;++i){
|
||||
constexpr std::size_t operator()(const T& t, std::size_t salt = 0)const noexcept{
|
||||
constexpr std::size_t bytes = sizeof(std::size_t);
|
||||
std::size_t val = static_cast<std::size_t>(t);
|
||||
std::size_t hash = 5381 + salt; //magic hash number
|
||||
for(std::size_t i = 0;i < bytes;++i){
|
||||
unsigned char c = static_cast<unsigned char>(val >> (i * CHAR_BIT));
|
||||
hash = ((hash << 5) + hash) ^ c;
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#define REXY_MPMC_QUEUE_HPP
|
||||
|
||||
#include <vector> //vector (duh)
|
||||
#include <cstdlib> //size_t
|
||||
#include <cstddef> //size_t
|
||||
#include <atomic> //atomic (duh)
|
||||
|
||||
#include "rexy.hpp"
|
||||
@ -43,7 +43,7 @@ namespace rexy{
|
||||
{
|
||||
public:
|
||||
using value_type = T;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using reference = value_type&;
|
||||
@ -55,13 +55,13 @@ namespace rexy{
|
||||
//libc++ bug
|
||||
// https://bugs.llvm.org/show_bug.cgi?id=41423
|
||||
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 12000
|
||||
static constexpr size_t cacheline_size = std::hardware_destructive_interference_size;
|
||||
static constexpr std::size_t cacheline_size = std::hardware_destructive_interference_size;
|
||||
#else
|
||||
static constexpr size_t cacheline_size = 64;
|
||||
static constexpr std::size_t cacheline_size = 64;
|
||||
#endif
|
||||
#else
|
||||
//Best guess
|
||||
static constexpr size_t cacheline_size = 64;
|
||||
static constexpr std::size_t cacheline_size = 64;
|
||||
#endif
|
||||
|
||||
class slot
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include <type_traits> //is_same, integral_contant, enable_if, etc
|
||||
#include <utility> //forward
|
||||
#include <cstddef> //size_t,ptrdiff
|
||||
#include <cstddef> //std::size_t,ptrdiff
|
||||
#include <cstring> //strlen
|
||||
#include <climits> //CHAR_BIT
|
||||
#include <iterator> //reverse_iterator
|
||||
@ -54,7 +54,7 @@ namespace rexy{
|
||||
{
|
||||
public:
|
||||
using value_type = Char;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
|
||||
@ -26,9 +26,9 @@ namespace rexy{
|
||||
//jenkns one at a time hash
|
||||
template<class Str>
|
||||
struct string_hash{
|
||||
constexpr size_t operator()(const Str& s, size_t salt = 0)const noexcept{
|
||||
size_t hash = salt;
|
||||
for(size_t i = 0;i < s.length();++i){
|
||||
constexpr std::size_t operator()(const Str& s, std::size_t salt = 0)const noexcept{
|
||||
std::size_t hash = salt;
|
||||
for(std::size_t i = 0;i < s.length();++i){
|
||||
hash += s[i];
|
||||
hash += (hash << 10);
|
||||
hash += (hash >> 6);
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#ifndef REXY_STRING_VIEW_HPP
|
||||
#define REXY_STRING_VIEW_HPP
|
||||
|
||||
#include <cstddef> //size_t, ptrdiff_t
|
||||
#include <cstddef> //std::size_t, ptrdiff_t
|
||||
#include <iterator> //reverse_iterator
|
||||
|
||||
#include "compat/standard.hpp"
|
||||
@ -35,7 +35,7 @@ namespace rexy{
|
||||
{
|
||||
public:
|
||||
using value_type = Char;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
@ -132,7 +132,7 @@ namespace rexy{
|
||||
template<class T>
|
||||
basic_string_view(const T*) -> basic_string_view<T>;
|
||||
template<class T>
|
||||
basic_string_view(const T*, size_t) -> basic_string_view<T>;
|
||||
basic_string_view(const T*, std::size_t) -> basic_string_view<T>;
|
||||
|
||||
using string_view = basic_string_view<char>;
|
||||
using wstring_view = basic_string_view<wchar_t>;
|
||||
@ -146,16 +146,16 @@ namespace rexy{
|
||||
|
||||
inline namespace str_literals{
|
||||
|
||||
constexpr inline rexy::basic_string_view<char> operator"" _sv(const char* str, size_t len)noexcept{
|
||||
constexpr inline rexy::basic_string_view<char> operator"" _sv(const char* str, std::size_t len)noexcept{
|
||||
return rexy::basic_string_view(str, len);
|
||||
}
|
||||
constexpr inline rexy::basic_string_view<wchar_t> operator"" _sv(const wchar_t* str, size_t len)noexcept{
|
||||
constexpr inline rexy::basic_string_view<wchar_t> operator"" _sv(const wchar_t* str, std::size_t len)noexcept{
|
||||
return rexy::basic_string_view(str, len);
|
||||
}
|
||||
constexpr inline rexy::basic_string_view<char16_t> operator"" _sv(const char16_t* str, size_t len)noexcept{
|
||||
constexpr inline rexy::basic_string_view<char16_t> operator"" _sv(const char16_t* str, std::size_t len)noexcept{
|
||||
return rexy::basic_string_view(str, len);
|
||||
}
|
||||
constexpr inline rexy::basic_string_view<char32_t> operator"" _sv(const char32_t* str, size_t len)noexcept{
|
||||
constexpr inline rexy::basic_string_view<char32_t> operator"" _sv(const char32_t* str, std::size_t len)noexcept{
|
||||
return rexy::basic_string_view(str, len);
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#define REXY_UTILITY_HPP
|
||||
|
||||
#include <utility> //forward, move
|
||||
#include <cstdlib> //size_t
|
||||
#include <cstddef> //size_t
|
||||
#include <type_traits>
|
||||
#include <cstring> //strlen, strcmp, memcpy
|
||||
#include <cwchar> //wcslen
|
||||
@ -50,7 +50,7 @@ namespace rexy{
|
||||
}
|
||||
return start2;
|
||||
}
|
||||
template<class T, size_t N>
|
||||
template<class T, std::size_t N>
|
||||
constexpr void swap(T (&l)[N], T (&r)[N])
|
||||
noexcept(noexcept(swap(*l, *r)))
|
||||
{
|
||||
@ -94,7 +94,7 @@ namespace rexy{
|
||||
|
||||
#ifdef REXY_if_consteval
|
||||
template<class T>
|
||||
constexpr size_t strlen(const T* c)noexcept{
|
||||
constexpr std::size_t strlen(const T* c)noexcept{
|
||||
return std::char_traits<T>::length(c);
|
||||
}
|
||||
template<class T>
|
||||
@ -138,13 +138,13 @@ namespace rexy{
|
||||
for(;cmp(*l, *r) && *l;++l, ++r);
|
||||
return *l - *r;
|
||||
}
|
||||
constexpr void memcpy(void* l, const void* r, size_t n){
|
||||
constexpr void memcpy(void* l, const void* r, std::size_t n){
|
||||
REXY_if_consteval{
|
||||
std::memcpy(l, r, n);
|
||||
}else{
|
||||
char* ld = static_cast<char*>(l);
|
||||
const char* rd = static_cast<const char*>(r);
|
||||
for(size_t i = 0;i < n;++i){
|
||||
for(std::size_t i = 0;i < n;++i){
|
||||
ld[i] = rd[i];
|
||||
}
|
||||
}
|
||||
@ -152,8 +152,8 @@ namespace rexy{
|
||||
}
|
||||
#else // REXY_if_consteval
|
||||
template<class T>
|
||||
constexpr size_t strlen(const T* c)noexcept{
|
||||
size_t i = 0;
|
||||
constexpr std::size_t strlen(const T* c)noexcept{
|
||||
std::size_t i = 0;
|
||||
for(;c[i];++i);
|
||||
return i;
|
||||
}
|
||||
@ -172,10 +172,10 @@ namespace rexy{
|
||||
for(std::size_t i = 0;*l == *r && *l && i < max;++i, ++l, ++r);
|
||||
return *l - *r;
|
||||
}
|
||||
constexpr void memcpy(void* l, const void* r, size_t n){
|
||||
constexpr void memcpy(void* l, const void* r, std::size_t n){
|
||||
char* ld = static_cast<char*>(l);
|
||||
const char* rd = static_cast<const char*>(r);
|
||||
for(size_t i = 0;i < n;++i){
|
||||
for(std::size_t i = 0;i < n;++i){
|
||||
ld[i] = rd[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,20 +39,20 @@ namespace rexy{
|
||||
FILE* filerd::release(void)noexcept{
|
||||
return std::exchange(m_fp, nullptr);
|
||||
}
|
||||
size_t filerd::length(void)noexcept{
|
||||
std::size_t filerd::length(void)noexcept{
|
||||
if(!m_fp)
|
||||
return 0;
|
||||
size_t tmp, ret;
|
||||
std::size_t tmp, ret;
|
||||
tmp = ftell(m_fp);
|
||||
fseek(m_fp, 0, SEEK_END);
|
||||
ret = ftell(m_fp);
|
||||
fseek(m_fp, tmp, SEEK_SET);
|
||||
return ret;
|
||||
}
|
||||
size_t filerd::position(void)const noexcept{
|
||||
std::size_t filerd::position(void)const noexcept{
|
||||
return ftell(m_fp);
|
||||
}
|
||||
void filerd::rewind(size_t pos)noexcept{
|
||||
void filerd::rewind(std::size_t pos)noexcept{
|
||||
fseek(m_fp, pos, SEEK_SET);
|
||||
}
|
||||
|
||||
@ -72,20 +72,20 @@ namespace rexy{
|
||||
return m_fp;
|
||||
}
|
||||
|
||||
size_t filerd::read(char* dest, size_t bytes)noexcept{
|
||||
std::size_t filerd::read(char* dest, std::size_t bytes)noexcept{
|
||||
return fread(dest, 1, bytes, m_fp);
|
||||
}
|
||||
rexy::string filerd::read(size_t bytes)noexcept{
|
||||
rexy::string filerd::read(std::size_t bytes)noexcept{
|
||||
rexy::string ret;
|
||||
char* tmp = ret.allocator().allocate(bytes);
|
||||
size_t written = read(tmp, bytes);
|
||||
std::size_t written = read(tmp, bytes);
|
||||
ret.reset(tmp, written);
|
||||
return ret;
|
||||
}
|
||||
rexy::string filerd::readln(size_t max)noexcept{
|
||||
rexy::string filerd::readln(std::size_t max)noexcept{
|
||||
rexy::string ret;
|
||||
int c;
|
||||
size_t count = 0;
|
||||
std::size_t count = 0;
|
||||
for(c = fgetc(m_fp);c != EOF && c != '\n';c = fgetc(m_fp)){
|
||||
char ch = c;
|
||||
ret.append(&ch, 1);
|
||||
@ -94,18 +94,18 @@ namespace rexy{
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
rexy::buffer<char> filerd::read_bin(size_t bytes)
|
||||
noexcept(std::is_nothrow_constructible<rexy::buffer<char>, char*, size_t>::value)
|
||||
rexy::buffer<char> filerd::read_bin(std::size_t bytes)
|
||||
noexcept(std::is_nothrow_constructible<rexy::buffer<char>, char*, std::size_t>::value)
|
||||
{
|
||||
rexy::buffer<char> ret{bytes};
|
||||
size_t written = read(ret.data(), bytes);
|
||||
std::size_t written = read(ret.data(), bytes);
|
||||
ret.set_size(written);
|
||||
return ret;
|
||||
}
|
||||
size_t filerd::write(const char* c, size_t bytes)noexcept{
|
||||
std::size_t filerd::write(const char* c, std::size_t bytes)noexcept{
|
||||
return fwrite(c, 1, bytes, m_fp);
|
||||
}
|
||||
size_t filerd::write(const rexy::string_base<char>& c)noexcept{
|
||||
std::size_t filerd::write(const rexy::string_base<char>& c)noexcept{
|
||||
return write(c.data(), c.length());
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ namespace rexy{
|
||||
m_valid(true)
|
||||
{
|
||||
m_ctor_lock.unlock();
|
||||
for(size_t i = 0;i < other.m_workers.size();++i){
|
||||
for(std::size_t i = 0;i < other.m_workers.size();++i){
|
||||
m_workers.emplace_back(&threadpool::worker_loop, this);
|
||||
}
|
||||
m_qcv.notify_all();
|
||||
|
||||
@ -90,7 +90,7 @@ void check_short_construction(){
|
||||
}
|
||||
void check_long_construction(){
|
||||
const char* data = "this is a really long string that should ensure that it makes a dynamic allocation even if it has a big buffer.";
|
||||
size_t len = strlen(data);
|
||||
std::size_t len = strlen(data);
|
||||
test_str str1(data);
|
||||
if(str1.length() != len)
|
||||
error("long constructed string should be length() == strlen(data)\n");
|
||||
@ -171,7 +171,7 @@ void check_long_assignment(){
|
||||
const char* startdata1 = "this is another really long string that should ensure that it makes some sort of dyn alloc for big buf";
|
||||
const char* startdata2 = "zy";
|
||||
const char* data = "this is a really long string that should ensure that it makes a dynamic allocation even if it has a big buffer.";
|
||||
size_t len = strlen(data);
|
||||
std::size_t len = strlen(data);
|
||||
test_str str1(startdata1);
|
||||
str1 = data;
|
||||
if(str1.length() != len)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user