Skip to content

Commit 06a4420

Browse files
committed
fix(type-sequence): refactoring and fixing
1 parent 5c66c69 commit 06a4420

File tree

6 files changed

+485
-397
lines changed

6 files changed

+485
-397
lines changed

include/stdsharp/functional/invoke.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#pragma once
22

3-
#include <functional>
4-
53
#include "../macros.h"
64
#include "../namespace_alias.h"
75

6+
#include <functional>
7+
88
namespace stdsharp
99
{
1010
inline constexpr struct invoke_fn
1111
{
12-
constexpr decltype(auto) operator()(auto&&... args) const noexcept(noexcept(std::invoke(cpp_forward(args)...)))
12+
constexpr auto operator()(auto&&... args) const
13+
noexcept(noexcept(std::invoke(cpp_forward(args)...))) //
14+
-> decltype(std::invoke(cpp_forward(args)...))
1315
{
1416
return std::invoke(cpp_forward(args)...);
1517
}

include/stdsharp/iterator/iterator.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#pragma once
22

3+
#include "../namespace_alias.h"
4+
35
#include <iterator>
46

5-
#include "../type_traits/core_traits.h"
67

78
namespace stdsharp
89
{
@@ -19,16 +20,12 @@ namespace stdsharp
1920
concept weakly_decrementable = std::movable<T> && requires(T i) {
2021
typename std::iter_difference_t<T>;
2122
requires std::signed_integral<std::iter_difference_t<T>>;
22-
{
23-
--i
24-
} -> std::same_as<T&>;
23+
{ --i } -> std::same_as<T&>;
2524
i--;
2625
};
2726

2827
template<typename T>
2928
concept decrementable = std::regular<T> && weakly_decrementable<T> && requires(T i) {
30-
{
31-
i--
32-
} -> std::same_as<T>;
29+
{ i-- } -> std::same_as<T>;
3330
};
3431
}

include/stdsharp/type_traits/type_sequence.h

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,48 @@ namespace stdsharp::details
1919
template<typename Seq>
2020
using type_seq_converter_t = type_seq_converter<Seq>::type;
2121

22-
template<typename Base, typename... Types>
23-
struct STDSHARP_EBO type_sequence : private Base, regular_type_sequence<Types...>
22+
template<typename... Types>
23+
struct type_sequence
2424
{
25-
using Base::adjacent_find;
26-
using Base::all_of;
27-
using Base::any_of;
28-
using Base::contains;
29-
using Base::count;
30-
using Base::count_if;
31-
using Base::count_if_not;
32-
using Base::find;
33-
using Base::find_if;
34-
using Base::find_if_not;
35-
using Base::for_each;
36-
using Base::for_each_n;
37-
using Base::none_of;
38-
using Base::size;
25+
private:
26+
using value_sequence = value_sequence<basic_type_constant<Types>{}...>;
3927

40-
template<template<typename...> typename T>
41-
using apply_t = T<Types...>;
28+
public:
29+
static constexpr std::size_t size() noexcept { return sizeof...(Types); }
4230

4331
template<std::size_t I>
44-
using type = Base::template value_type<I>::type;
45-
46-
template<std::size_t... I>
47-
using at_t = regular_type_sequence<type<I>...>;
48-
49-
template<std::size_t Size>
50-
using back_t = type_seq_converter_t<typename Base::template back_t<Size>>;
32+
using type = type_at<I, Types...>;
5133

52-
template<std::size_t Size>
53-
using front_t = type_seq_converter_t<typename Base::template front_t<Size>>;
34+
template<template<typename...> typename T>
35+
using apply_t = T<Types...>;
5436

5537
template<typename... Others>
5638
using append_t = regular_type_sequence<Types..., Others...>;
5739

40+
template<auto... Func>
41+
using transform_fn = value_sequence::template transform_fn<Func...>;
42+
43+
template<auto... Func>
44+
static constexpr transform_fn<Func...> transform{};
45+
46+
template<auto... Func>
47+
requires std::invocable<transform_fn<Func...>>
48+
using transform_t = decltype(transform<Func...>());
49+
5850
template<typename T = void>
59-
using invoke_fn = Base::template invoke_fn<T>;
51+
using invoke_fn = value_sequence::template invoke_fn<T>;
6052

61-
template<typename T = empty_t>
53+
template<typename T = void>
6254
static constexpr invoke_fn<T> invoke{};
6355

56+
using for_each_fn = value_sequence::for_each_fn;
57+
58+
static constexpr for_each_fn for_each{};
59+
60+
template<std::size_t From, std::size_t Size>
61+
using select_range_t =
62+
type_seq_converter_t<typename value_sequence::template select_range_t<From, Size>>;
63+
6464
template<typename... Others>
6565
using append_front_t = regular_type_sequence<Others..., Types...>;
6666

@@ -75,14 +75,6 @@ namespace stdsharp::details
7575
using replace_t = type_seq_converter_t<
7676
typename Base::template replace_t<Index, basic_type_constant<Other>{}>>;
7777

78-
template<std::size_t From, std::size_t Size>
79-
using select_range_t =
80-
type_seq_converter_t<typename Base::template select_range_t<From, Size>>;
81-
82-
using reverse_t = details::type_seq_converter_t<typename Base::reverse_t>;
83-
84-
template<typename Cmp>
85-
using unique_t = details::type_seq_converter_t<typename Base::template unique_t<Cmp>>;
8678
};
8779
}
8880

0 commit comments

Comments
 (0)