diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fb16b3..d874adb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ option(BUILD_TESTS "Enable testing" OFF) option(BUILD_HEADER_ONLY "Enable header only build" OFF) mark_as_advanced(ENABLE_PROFILING) -set(LIBREXY_PUBLIC_HEADERS "include/rexy/rexy.hpp" "include/rexy/algorithm.hpp" "include/rexy/algorithm.tpp" "include/rexy/utility.hpp" "include/rexy/basic_string_hash.hpp" "include/rexy/hash.hpp" "include/rexy/string_view_hash.hpp" "include/rexy/string_hash.hpp" "include/rexy/mpmc_queue.hpp" "include/rexy/mpmc_queue.tpp" "include/rexy/traits.hpp" "include/rexy/steal.hpp" "include/rexy/expression.hpp" "include/rexy/string_base.hpp" "include/rexy/string.hpp" "include/rexy/string_base.tpp" "include/rexy/allocator.hpp" "include/rexy/meta.hpp" "include/rexy/buffer.hpp" "include/rexy/buffer.tpp" "include/rexy/debug_print.hpp" "include/rexy/deferred.hpp" "include/rexy/enum_traits.hpp" "include/rexy/storage_for.hpp" "include/rexy/storage_for.tpp" "include/rexy/visitor.hpp" "include/rexy/string_view.hpp" "include/rexy/string_view.tpp" "include/rexy/format.hpp" "include/rexy/format.tpp") +set(LIBREXY_PUBLIC_HEADERS "include/rexy/rexy.hpp" "include/rexy/algorithm.hpp" "include/rexy/algorithm.tpp" "include/rexy/utility.hpp" "include/rexy/hash.hpp" "include/rexy/mpmc_queue.hpp" "include/rexy/mpmc_queue.tpp" "include/rexy/traits.hpp" "include/rexy/steal.hpp" "include/rexy/expression.hpp" "include/rexy/string_base.hpp" "include/rexy/string.hpp" "include/rexy/string_base.tpp" "include/rexy/allocator.hpp" "include/rexy/meta.hpp" "include/rexy/buffer.hpp" "include/rexy/buffer.tpp" "include/rexy/debug_print.hpp" "include/rexy/deferred.hpp" "include/rexy/enum_traits.hpp" "include/rexy/storage_for.hpp" "include/rexy/storage_for.tpp" "include/rexy/visitor.hpp" "include/rexy/string_view.hpp" "include/rexy/string_view.tpp" "include/rexy/format.hpp" "include/rexy/format.tpp") if(BUILD_HEADER_ONLY) set(LIBREXY_BUILT_LIBRARY_HEADERS "") diff --git a/include/rexy/basic_string_hash.hpp b/include/rexy/basic_string_hash.hpp deleted file mode 100644 index bcc2ba6..0000000 --- a/include/rexy/basic_string_hash.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/** - This file is a part of rexy's general purpose library - Copyright (C) 2020 rexy712 - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef REXY_BASIC_STRING_HASH_HPP -#define REXY_BASIC_STRING_HASH_HPP - -#include "string_hash.hpp" -#include "string.hpp" - -#include "rexy.hpp" - -namespace rexy{ - - template<> - struct hash : public string_hash{}; - -} - -#endif diff --git a/include/rexy/cx/cx_string_hash.hpp b/include/rexy/cx/cx_string_hash.hpp deleted file mode 100644 index 7327d6b..0000000 --- a/include/rexy/cx/cx_string_hash.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/** - This file is a part of rexy's general purpose library - Copyright (C) 2020 rexy712 - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef REXY_CX_CX_STRING_HASH_HPP -#define REXY_CX_CX_STRING_HASH_HPP - -#include "../string_hash.hpp" -#include "string.hpp" - -namespace rexy::cx{ - - template - struct hash> : public string_hash>{}; - -} - -#endif diff --git a/include/rexy/cx/hashmap.hpp b/include/rexy/cx/hashmap.hpp index 275a7b5..9c8660f 100644 --- a/include/rexy/cx/hashmap.hpp +++ b/include/rexy/cx/hashmap.hpp @@ -89,8 +89,4 @@ namespace rexy::cx{ #include "hashmap.tpp" -#ifdef REXY_STRING_BASE_HPP -#include "../string_hash.hpp" -#endif - #endif diff --git a/include/rexy/cx/string.hpp b/include/rexy/cx/string.hpp index 79fb66d..d5aa7a4 100644 --- a/include/rexy/cx/string.hpp +++ b/include/rexy/cx/string.hpp @@ -35,7 +35,6 @@ namespace rexy::cx{ #include //reverse_iterator #include "../compat/standard.hpp" -#include "../compat/string_base.hpp" //This is different from rexy::string_view in that this doesn't hold a pointer to a constant string array. //This holds a mutable array of data which can be modified during compile time. string_view is @@ -105,7 +104,7 @@ namespace rexy::cx{ } template constexpr string(const rexy::string_cat_expr& expr) - noexcept(std::is_nothrow_invocable>, decltype(expr)>::value) + noexcept(std::is_nothrow_invocable>, decltype(expr)>::value) { rexy::detail::string_appender> append(*this); append(expr); @@ -225,7 +224,7 @@ namespace rexy::cx{ template static std::true_type check(cx::string); static std::false_type check(...); - static constexpr bool value = (decltype(check(std::declval>()))::value && ...); + static constexpr bool value = (decltype(check(std::declval>()))::value && ...); }; } @@ -236,8 +235,5 @@ namespace rexy::cx{ #include "../compat/cpp17/cx/string.hpp" #endif //__cpp_concepts -#ifdef REXY_CX_HASH_HPP -#include "cx_string_hash.hpp" -#endif #endif diff --git a/include/rexy/deferred.hpp b/include/rexy/deferred.hpp index af47af5..c3f3eae 100644 --- a/include/rexy/deferred.hpp +++ b/include/rexy/deferred.hpp @@ -21,6 +21,9 @@ #include #include //forward, index_sequence +#include //size_t + +#include "compat/standard.hpp" namespace rexy{ template @@ -36,11 +39,11 @@ namespace rexy{ template constexpr deferred(FArgs&&... args); - deferred(const deferred&) = default; - deferred(deferred&&) = default; - ~deferred(void) = default; - deferred& operator=(const deferred&) = default; - deferred& operator=(deferred&&) = default; + REXY_CPP20_CONSTEXPR deferred(const deferred&) = default; + REXY_CPP20_CONSTEXPR deferred(deferred&&) = default; + REXY_CPP20_CONSTEXPR ~deferred(void) = default; + REXY_CPP20_CONSTEXPR deferred& operator=(const deferred&) = default; + REXY_CPP20_CONSTEXPR deferred& operator=(deferred&&) = default; constexpr value_type value(void); constexpr operator value_type(void); diff --git a/include/rexy/detail/string_appender.hpp b/include/rexy/detail/string_appender.hpp index f35ad0a..72631e0 100644 --- a/include/rexy/detail/string_appender.hpp +++ b/include/rexy/detail/string_appender.hpp @@ -20,8 +20,8 @@ #define REXY_STRING_APPENDER_HPP #include "../expression.hpp" -#include "../traits.hpp" #include //forward +#include //enable_if, declval namespace rexy::detail{ @@ -49,12 +49,7 @@ namespace rexy::detail{ template::value,int> = 0, class = decltype(std::declval().length())> constexpr void operator()(Val&& v) { - m_targ.append(std::forward(v).get(), std::forward(v).length()); - } - template::value,void*> = nullptr, class = decltype(std::declval().size())> - constexpr void operator()(Val&& v) - { - m_targ.append(std::forward(v).get(), std::forward(v).size()); + m_targ.append(std::forward(v).data(), std::forward(v).length()); } }; diff --git a/include/rexy/filerd.hpp b/include/rexy/filerd.hpp index 64e3843..7db8425 100644 --- a/include/rexy/filerd.hpp +++ b/include/rexy/filerd.hpp @@ -19,6 +19,8 @@ #ifndef REXY_FILERD_HPP #define REXY_FILERD_HPP +#ifndef LIBREXY_HEADER_ONLY + #include //FILE #include //size_t #include //is_nothrow_constructible @@ -29,7 +31,6 @@ #include "rexy.hpp" #include "buffer.hpp" -#ifndef LIBREXY_HEADER_ONLY namespace rexy{ diff --git a/include/rexy/hash.hpp b/include/rexy/hash.hpp index 9695530..ce58626 100644 --- a/include/rexy/hash.hpp +++ b/include/rexy/hash.hpp @@ -1,6 +1,6 @@ /** This file is a part of rexy's general purpose library - Copyright (C) 2020 rexy712 + Copyright (C) 2020-2022 rexy712 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,10 +20,22 @@ #define REXY_HASH_HPP #include //CHAR_BIT +#include //size_t #include "rexy.hpp" +#include "allocator.hpp" + namespace rexy{ + template + class basic_string; + template + class basic_string_view; + namespace cx{ + template + class string; + } + template struct hash{ constexpr std::size_t operator()(const T& t, std::size_t salt = 0)const noexcept{ @@ -38,16 +50,32 @@ namespace rexy{ } }; + namespace detail{ + //jenkins one at a time hash + template + struct string_hash{ + 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); + } + hash += (hash << 3); + hash ^= (hash << 11); + hash += (hash << 15); + return hash; + } + }; + } + + template + struct hash> : public detail::string_hash>{}; + template + struct hash> : public detail::string_hash>{}; + template + struct hash> : public detail::string_hash>{}; + } -#ifdef REXY_STRING_VIEW_HPP -#include "string_view_hash.hpp" -#endif -#ifdef REXY_STRING_HPP -#include "basic_string_hash.hpp" -#endif -#ifdef REXY_CX_STRING_HPP -#include "cx/cx_string_hash.hpp" -#endif - #endif diff --git a/include/rexy/string.hpp b/include/rexy/string.hpp index 5006c0f..440bdf3 100644 --- a/include/rexy/string.hpp +++ b/include/rexy/string.hpp @@ -47,8 +47,4 @@ namespace rexy{ } -#ifdef REXY_CX_HASH_HPP -#include "cx/basic_string_hash.hpp" -#endif - #endif diff --git a/include/rexy/string_hash.hpp b/include/rexy/string_hash.hpp deleted file mode 100644 index 1c823bf..0000000 --- a/include/rexy/string_hash.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/** - This file is a part of rexy's general purpose library - Copyright (C) 2020 rexy712 - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef REXY_STRING_HASH_HPP -#define REXY_STRING_HASH_HPP - -#include "rexy.hpp" - -namespace rexy{ - - //jenkns one at a time hash - template - struct string_hash{ - 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); - } - hash += (hash << 3); - hash ^= (hash << 11); - hash += (hash << 15); - return hash; - } - }; - -} - -#endif diff --git a/include/rexy/string_view.hpp b/include/rexy/string_view.hpp index 5188ac1..812e0f7 100644 --- a/include/rexy/string_view.hpp +++ b/include/rexy/string_view.hpp @@ -173,8 +173,4 @@ namespace{ #include "string_view.tpp" -#ifdef REXY_HASH_HPP - #include "string_view_hash.hpp" -#endif - #endif diff --git a/include/rexy/string_view_hash.hpp b/include/rexy/string_view_hash.hpp deleted file mode 100644 index c84070b..0000000 --- a/include/rexy/string_view_hash.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - This file is a part of rexy's general purpose library - Copyright (C) 2020-2022 rexy712 - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef REXY_STRING_VIEW_HASH_HPP -#define REXY_STRING_VIEW_HASH_HPP - -#include "string_hash.hpp" -#include "string_view.hpp" -#include "rexy.hpp" - -namespace rexy{ - - template - struct hash> : public string_hash>{}; - -} - -#endif diff --git a/src/ensure.cpp b/src/ensure.cpp index 86e0dcd..369f314 100644 --- a/src/ensure.cpp +++ b/src/ensure.cpp @@ -11,7 +11,6 @@ #include "rexy/steal.hpp" #include "rexy/string_base.hpp" #include "rexy/string_base.tpp" -#include "rexy/string_hash.hpp" #include "rexy/string.hpp" #include "rexy/traits.hpp" #include "rexy/utility.hpp"