Skip to content

Commit

Permalink
expected in C++17
Browse files Browse the repository at this point in the history
  • Loading branch information
wjr-z committed Jul 15, 2024
1 parent f29c1bd commit d00550e
Show file tree
Hide file tree
Showing 86 changed files with 3,041 additions and 1,308 deletions.
2,087 changes: 1,527 additions & 560 deletions godbolt/wjr.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/wjr/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author wjr
* @brief Assertion utilities
*
* @details WJR_DEBUG_LEVEL : 0 ~ 3 \n
* @detail WJR_DEBUG_LEVEL : 0 ~ 3 \n
* 0 : Release \n
* 1 : Beta \n
* 2 : Runtime detect \n
Expand Down
175 changes: 93 additions & 82 deletions include/wjr/biginteger/biginteger.hpp

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions include/wjr/capture_leaf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class capture_leaf : enable_special_members_of_args_base<Tag, T> {
constexpr capture_leaf() noexcept(std::is_nothrow_constructible_v<T>)
: Mybase(enable_default_constructor), m_value() {}

template <typename... Args, WJR_REQUIRES(std::is_constructible_v<T, Args &&...>)>
template <typename... Args, WJR_REQUIRES(std::is_constructible_v<T, Args...>)>
constexpr capture_leaf(Args &&...args) noexcept(
std::is_constructible_v<T, Args &&...>)
std::is_constructible_v<T, Args...>)
: Mybase(enable_default_constructor), m_value(std::forward<Args>(args)...) {}

template <typename Ty = T, WJR_REQUIRES(std::is_default_constructible_v<Ty>)>
Expand All @@ -48,7 +48,7 @@ class capture_leaf : enable_special_members_of_args_base<Tag, T> {
*
* @brief Compressed capture any type as a new type.
*
* @details Use `EBO`(empty base optimization) to compress the size of the object.
* @detail Use `EBO`(empty base optimization) to compress the size of the object.
*
*/
template <typename T, typename Tag = void>
Expand All @@ -62,9 +62,9 @@ class compressed_capture_leaf : T {
constexpr compressed_capture_leaf() noexcept(std::is_nothrow_constructible_v<T>)
: Mybase() {}

template <typename... Args, WJR_REQUIRES(std::is_constructible_v<T, Args &&...>)>
template <typename... Args, WJR_REQUIRES(std::is_constructible_v<T, Args...>)>
constexpr compressed_capture_leaf(Args &&...args) noexcept(
std::is_constructible_v<T, Args &&...>)
std::is_constructible_v<T, Args...>)
: Mybase(std::forward<Args>(args)...) {}

template <typename Ty = T, WJR_REQUIRES(std::is_default_constructible_v<Ty>)>
Expand All @@ -80,7 +80,7 @@ class compressed_capture_leaf : T {
*
* @brief Check if a class can be compressed.
*
* @details A class can be compressed if it is a `empty` `class`, and it is not `final`.
* @detail A class can be compressed if it is a `empty` `class`, and it is not `final`.
*
*/
template <typename T>
Expand Down Expand Up @@ -109,7 +109,7 @@ struct __is_tuple_like_impl<
/**
* @brief Use template<...>typename like to like all element of LP and RP.
*
* @details For example, like is std::is_assignable, LP is std::tuple<T0, U0>, RP is
* @detail For example, like is std::is_assignable, LP is std::tuple<T0, U0>, RP is
* std::tuple<T1, U1>. \n
* Then __is_tuple_like = std::conjunction<std::is_assignable<T0,
* T1>, std::is_assignable<U0, U1>>.
Expand Down Expand Up @@ -140,7 +140,7 @@ struct __is_tuple_test_impl<Test, std::index_sequence<Idxs...>, LP, RP,
/**
* @brief Use template<...>typename Test to test all element of LP and RP.
*
* @details For example, Test is std::is_assignable, LP is std::tuple<T0, U0>, RP is
* @detail For example, Test is std::is_assignable, LP is std::tuple<T0, U0>, RP is
* std::tuple<T1, U1>. \n
* Then __is_tuple_test = std::conjunction<std::is_assignable<T0,
* T1>, std::is_assignable<U0, U1>>.
Expand Down
4 changes: 2 additions & 2 deletions include/wjr/compressed_pair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace wjr {
/**
* @brief Select the base class of compressed_pair.
*
* @details For compressed_pair<T, U> : \n
* @detail For compressed_pair<T, U> : \n
* If `T` is @ref is_compressed_v "compressed" and `U` is not ref is_compressed_v
* "compressed", then the base class is
* @ref compressed_capture_leaf \<T> and @ref capture_leaf \<U>. \n
Expand Down Expand Up @@ -73,7 +73,7 @@ using __compressed_pair_base2 =
*
* @brief A pair used empty base optimization to reduce the size of the pair.
*
* @details See @ref compressed_pair_wrapper for the base class of compressed_pair. \n
* @detail See @ref compressed_pair_wrapper for the base class of compressed_pair. \n
* compressed_pair is final, so it can't be derived from. \n
* For example : \n
* @code
Expand Down
38 changes: 19 additions & 19 deletions include/wjr/container/generic/bplus_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @file bplus_tree.hpp
* @brief B+ tree implementation.
*
* @details The multiset/multimap/set/map adapter has not been implemented yet. The
* @detail The multiset/multimap/set/map adapter has not been implemented yet. The
* node_size should be set to 16 by default, and optimization has been made for queries
* less than or equal to 16. \n
* After improvement, the number of queries for the i-th query is
Expand Down Expand Up @@ -44,7 +44,7 @@ struct bplus_tree_inner_node;
template <typename Traits, bool InlineKeys>
struct bplus_tree_leaf_node;

namespace bplus_tree_details {
namespace bplus_tree_detail {

template <typename T, bool Inlined>
class inline_key {
Expand All @@ -55,11 +55,11 @@ class inline_key {
using reference = std::add_const_t<T> &;
using pointer = std::add_const_t<T> *;

constexpr inline_key() = default;
constexpr inline_key(const inline_key &other) = default;
constexpr inline_key(inline_key &&other) = default;
constexpr inline_key &operator=(const inline_key &other) = default;
constexpr inline_key &operator=(inline_key &&other) = default;
inline_key() = default;
inline_key(const inline_key &other) = default;
inline_key(inline_key &&other) = default;
inline_key &operator=(const inline_key &other) = default;
inline_key &operator=(inline_key &&other) = default;
~inline_key() = default;

constexpr inline_key(reference value) noexcept(
Expand All @@ -84,11 +84,11 @@ class inline_key<T, false> {
using reference = std::add_const_t<T> &;
using pointer = std::add_const_t<T> *;

constexpr inline_key() = default;
constexpr inline_key(const inline_key &other) = default;
constexpr inline_key(inline_key &&other) = default;
constexpr inline_key &operator=(const inline_key &other) = default;
constexpr inline_key &operator=(inline_key &&other) = default;
inline_key() = default;
inline_key(const inline_key &other) = default;
inline_key(inline_key &&other) = default;
inline_key &operator=(const inline_key &other) = default;
inline_key &operator=(inline_key &&other) = default;
~inline_key() = default;

constexpr inline_key(reference value) noexcept : m_ptr(std::addressof(value)) {}
Expand Down Expand Up @@ -134,7 +134,7 @@ WJR_INTRINSIC_INLINE static void copy_backward(Other *first, Other *last,
#endif
}

} // namespace bplus_tree_details
} // namespace bplus_tree_detail

template <typename Key, typename Value, typename Compare, size_t Size, bool Multi>
struct bplus_tree_traits {
Expand All @@ -147,17 +147,17 @@ struct bplus_tree_traits {

static constexpr size_t node_size = Size;
static constexpr bool is_inline_key =
bplus_tree_details::is_possible_inline_key_v<std::remove_const_t<key_type>> &&
bplus_tree_detail::is_possible_inline_key_v<std::remove_const_t<key_type>> &&
sizeof(key_type) <= 8;
static constexpr bool is_inline_value =
bplus_tree_details::is_possible_inline_key_v<std::remove_const_t<value_type>> &&
bplus_tree_detail::is_possible_inline_key_v<std::remove_const_t<value_type>> &&
sizeof(value_type) <= 8;

using InlineKey =
bplus_tree_details::inline_key<std::remove_const_t<key_type>, is_inline_key>;
bplus_tree_detail::inline_key<std::remove_const_t<key_type>, is_inline_key>;
using InlineValue = std::conditional_t<
is_inline_value,
bplus_tree_details::inline_key<std::remove_const_t<value_type>, true>,
bplus_tree_detail::inline_key<std::remove_const_t<value_type>, true>,
value_type *>;

using node_type = bplus_tree_node<bplus_tree_traits>;
Expand All @@ -179,13 +179,13 @@ struct bplus_tree_traits {
template <size_t Min = 0, size_t Max = node_size, typename Other = void>
WJR_INTRINSIC_INLINE static void copy(Other *first, Other *last,
Other *dest) noexcept {
return bplus_tree_details::copy<Min, Max>(first, last, dest);
return bplus_tree_detail::copy<Min, Max>(first, last, dest);
}

template <size_t Min = 0, size_t Max = node_size, typename Other = void>
WJR_INTRINSIC_INLINE static void copy_backward(Other *first, Other *last,
Other *dest) noexcept {
return bplus_tree_details::copy_backward<Min, Max>(first, last, dest);
return bplus_tree_detail::copy_backward<Min, Max>(first, last, dest);
}
};

Expand Down
2 changes: 1 addition & 1 deletion include/wjr/container/generic/container_fn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace wjr {
* @class container_fn<Alloc>
* @brief The same characteristics and behavior of all allocator containers
*
* @details container must have the following member functions:
* @detail container must have the following member functions:
* -# auto& __get_allocator() noexcept
* -# void __destroy() noexcept
* -# void __destroy_and_deallocate() noexcept
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef WJR_CONTAINER_GENERIC_DETAILS_HPP__
#define WJR_CONTAINER_GENERIC_DETAILS_HPP__
#ifndef WJR_CONTAINER_GENERIC_DETAIL_HPP__
#define WJR_CONTAINER_GENERIC_DETAIL_HPP__

#include <string>

#include <wjr/iterator/details.hpp>
#include <wjr/iterator/detail.hpp>

namespace wjr {

Expand Down Expand Up @@ -255,7 +255,7 @@ struct __container_traits_base {
constexpr static bool is_contiguous_v = is_contiguous_iterator_v<iterator>;

/**
* @details Trivially contiguous means that the container can be resized and then
* @detail Trivially contiguous means that the container can be resized and then
* filled, and the result should be consistent with the element by element push_back
* result. It does not verify whether the element is trial. Because different
* containers may have different ways of constructing elements. The main purpose is
Expand All @@ -272,4 +272,4 @@ struct container_traits;

} // namespace wjr

#endif // WJR_CONTAINER_GENERIC_DETAILS_HPP__
#endif // WJR_CONTAINER_GENERIC_DETAIL_HPP__
2 changes: 1 addition & 1 deletion include/wjr/container/generic/dynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class basic_dynamic_bitset {
/**
* @brief Use from_chars_2 to optimize the performance.
*
* @details Very fast conversion from string to uint64_t.
* @detail Very fast conversion from string to uint64_t.
*
* @note Only use from_chars_2 when type of T is uint64_t and CharT is char.
*/
Expand Down
21 changes: 15 additions & 6 deletions include/wjr/container/generic/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @file vector.hpp
* @brief Vector container with definable internal structure
*
* @details
* @detail
* Customized internal structure needs to follow the following function signature: \n
* -# storage() noexcept
* -# ~storage() noexcept
Expand Down Expand Up @@ -49,7 +49,7 @@
#include <wjr/compressed_pair.hpp>
#include <wjr/container/generic/container_fn.hpp>
#include <wjr/iterator/contiguous_iterator_adpater.hpp>
#include <wjr/math/details.hpp>
#include <wjr/math/detail.hpp>
#include <wjr/memory/copy.hpp>
#include <wjr/memory/temporary_value_allocator.hpp>

Expand Down Expand Up @@ -127,7 +127,7 @@ struct __unref_wrapper_helper<default_vector_size_reference<pointer, size_type>>
/**
* @brief Default vector storage
*
* @details Use one pointer ans two size_type currently.
* @detail Use one pointer ans two size_type currently.
*
*/
template <typename T, typename Alloc>
Expand Down Expand Up @@ -789,7 +789,7 @@ struct basic_vector_traits {
/**
* @brief Customized vector by storage.
*
* @details Type of pointer is same as iterator.
* @detail Type of pointer is same as iterator.
*
*/
template <typename Storage>
Expand Down Expand Up @@ -848,7 +848,6 @@ class basic_vector {
std::declval<_Alty &>()));

public:
WJR_CONSTEXPR20
basic_vector() noexcept(std::is_nothrow_default_constructible_v<_Alty>) = default;

WJR_CONSTEXPR20 explicit basic_vector(const allocator_type &al) noexcept(
Expand Down Expand Up @@ -2098,7 +2097,7 @@ using static_vector = basic_vector<static_vector_storage<T, Capacity, Alloc>>;
/**
* @brief A vector with fixed capacity by construction.
*
* @details Only allocate memory on construction and deallocation on destruction.
* @detail Only allocate memory on construction and deallocation on destruction.
* After construction, it cannot be expanded and can only be modified through move
* assignment. For example, vector that using stack allocator.
*/
Expand Down Expand Up @@ -2152,4 +2151,14 @@ bool operator>=(const basic_vector<Storage> &lhs, const basic_vector<Storage> &r

} // namespace wjr

namespace std {

template <typename Storage>
constexpr void swap(wjr::basic_vector<Storage> &lhs,
wjr::basic_vector<Storage> &rhs) noexcept(noexcept(lhs.swap(rhs))) {
lhs.swap(rhs);
}

} // namespace std

#endif // WJR_CONTAINER_GENERIC_CONTAINER_VECTOR_HPP__
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef WJR_CONTAINER_INTRUSIVE_DETAILS_HPP__
#define WJR_CONTAINER_INTRUSIVE_DETAILS_HPP__
#ifndef WJR_CONTAINER_INTRUSIVE_DETAIL_HPP__
#define WJR_CONTAINER_INTRUSIVE_DETAIL_HPP__

#include <wjr/type_traits.hpp>

Expand Down Expand Up @@ -30,4 +30,4 @@ inline constexpr bool intrusive_use_hook_v = Tag::use_hook;

} // namespace wjr

#endif // WJR_CONTAINER_INTRUSIVE_DETAILS_HPP__
#endif // WJR_CONTAINER_INTRUSIVE_DETAIL_HPP__
25 changes: 12 additions & 13 deletions include/wjr/container/intrusive/list.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef WJR_CONTAINER_INTRUSIVE_LIST_HPP__
#define WJR_CONTAINER_INTRUSIVE_LIST_HPP__

#include <wjr/container/intrusive/details.hpp>
#include <wjr/container/intrusive/detail.hpp>

namespace wjr {

Expand Down Expand Up @@ -53,12 +53,11 @@ class list_node_const_iterator {
using pointer = const node_type *;
using difference_type = std::ptrdiff_t;

constexpr list_node_const_iterator() = default;
constexpr list_node_const_iterator(const list_node_const_iterator &) = default;
constexpr list_node_const_iterator(list_node_const_iterator &&) = default;
constexpr list_node_const_iterator &
operator=(const list_node_const_iterator &) = default;
constexpr list_node_const_iterator &operator=(list_node_const_iterator &&) = default;
list_node_const_iterator() = default;
list_node_const_iterator(const list_node_const_iterator &) = default;
list_node_const_iterator(list_node_const_iterator &&) = default;
list_node_const_iterator &operator=(const list_node_const_iterator &) = default;
list_node_const_iterator &operator=(list_node_const_iterator &&) = default;
~list_node_const_iterator() = default;

constexpr list_node_const_iterator(pointer node) noexcept
Expand Down Expand Up @@ -115,11 +114,11 @@ class list_node_iterator : public list_node_const_iterator<T> {

using Mybase::Mybase;

constexpr list_node_iterator() = default;
constexpr list_node_iterator(const list_node_iterator &) = default;
constexpr list_node_iterator(list_node_iterator &&) = default;
constexpr list_node_iterator &operator=(const list_node_iterator &) = default;
constexpr list_node_iterator &operator=(list_node_iterator &&) = default;
list_node_iterator() = default;
list_node_iterator(const list_node_iterator &) = default;
list_node_iterator(list_node_iterator &&) = default;
list_node_iterator &operator=(const list_node_iterator &) = default;
list_node_iterator &operator=(list_node_iterator &&) = default;
~list_node_iterator() = default;

constexpr reference operator*() const noexcept {
Expand Down Expand Up @@ -160,7 +159,7 @@ struct list_node {
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

constexpr list_node() = default;
list_node() = default;
list_node(const list_node &) = delete;
list_node(list_node &&) = delete;
list_node &operator=(const list_node &) = delete;
Expand Down
Loading

0 comments on commit d00550e

Please sign in to comment.