Skip to content

Commit cd47cf0

Browse files
committed
Merge branch 'cleanup' into v2
2 parents 0d11261 + 2fefc01 commit cd47cf0

20 files changed

+838
-650
lines changed

include/yorel/yomm2/core.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ struct virtual_;
2323
template<class Class, class Policy>
2424
struct virtual_ptr;
2525

26-
} // namespace yomm2
27-
} // namespace yorel
28-
29-
#include <yorel/yomm2/detail.hpp>
30-
31-
namespace yorel {
32-
namespace yomm2 {
33-
3426
// -----------------------------------------------------------------------------
3527
// Method
3628

@@ -41,7 +33,7 @@ template<typename Key, typename R, class Policy, typename... A>
4133
struct method<Key, R(A...), Policy> : detail::method_info {
4234
using self_type = method;
4335
using policy_type = Policy;
44-
using declared_argument_types = boost::mp11::mp_list<A...>;
36+
using declared_argument_types = detail::types<A...>;
4537
using call_argument_types = boost::mp11::mp_transform<
4638
detail::remove_virtual, declared_argument_types>;
4739
using virtual_argument_types =
@@ -190,7 +182,7 @@ struct class_declaration
190182
detail::get_policy<Classes...>, detail::remove_policy<Classes...>> {};
191183

192184
template<class... Classes>
193-
struct class_declaration<boost::mp11::mp_list<Classes...>>
185+
struct class_declaration<detail::types<Classes...>>
194186
: detail::class_declaration_aux<
195187
detail::get_policy<Classes...>, detail::remove_policy<Classes...>> {};
196188

@@ -453,9 +445,9 @@ method<Key, R(A...), Policy>::resolve(const ArgType&... args) const {
453445
std::uintptr_t pf;
454446

455447
if constexpr (arity == 1) {
456-
pf = resolve_uni<boost::mp11::mp_list<A...>, ArgType...>(args...);
448+
pf = resolve_uni<types<A...>, ArgType...>(args...);
457449
} else {
458-
pf = resolve_multi_first<0, boost::mp11::mp_list<A...>, ArgType...>(
450+
pf = resolve_multi_first<0, types<A...>, ArgType...>(
459451
args...);
460452
}
461453

include/yorel/yomm2/detail.hpp

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
#ifndef YOREL_YOMM2_DETAIL_HPP
22
#define YOREL_YOMM2_DETAIL_HPP
33

4-
#include <boost/assert.hpp>
5-
#include <boost/dynamic_bitset.hpp>
6-
#include <boost/mp11/algorithm.hpp>
7-
#include <boost/mp11/bind.hpp>
8-
94
#include <yorel/yomm2/detail/static_list.hpp>
105

6+
#include <boost/assert.hpp>
7+
118
namespace yorel {
129
namespace yomm2 {
1310
namespace detail {
@@ -25,7 +22,7 @@ template<class Policy, class TypeList>
2522
struct type_id_list;
2623

2724
template<class Policy, typename... T>
28-
struct type_id_list<Policy, boost::mp11::mp_list<T...>> {
25+
struct type_id_list<Policy, types<T...>> {
2926
// If using deferred 'static_type', add an extra element in 'value',
3027
// default-initialized to zero, indicating the ids need to be resolved. Set
3128
// to 1 after this is done.
@@ -37,18 +34,18 @@ struct type_id_list<Policy, boost::mp11::mp_list<T...>> {
3734
};
3835

3936
template<class Policy, typename... T>
40-
type_id type_id_list<Policy, boost::mp11::mp_list<T...>>::value[values] = {
37+
type_id type_id_list<Policy, types<T...>>::value[values] = {
4138
collect_static_type_id<Policy, T>()...};
4239

4340
template<class Policy, typename... T>
44-
type_id* type_id_list<Policy, boost::mp11::mp_list<T...>>::begin = value;
41+
type_id* type_id_list<Policy, types<T...>>::begin = value;
4542

4643
template<class Policy, typename... T>
47-
type_id* type_id_list<Policy, boost::mp11::mp_list<T...>>::end =
44+
type_id* type_id_list<Policy, types<T...>>::end =
4845
value + sizeof...(T);
4946

5047
template<class Policy>
51-
struct type_id_list<Policy, boost::mp11::mp_list<>> {
48+
struct type_id_list<Policy, types<>> {
5249
static constexpr type_id* const begin = nullptr;
5350
static constexpr auto end = begin;
5451
};
@@ -70,12 +67,12 @@ struct parameter_type_list;
7067

7168
template<typename ReturnType, typename... ParameterTypes>
7269
struct parameter_type_list<ReturnType(ParameterTypes...)> {
73-
using type = boost::mp11::mp_list<ParameterTypes...>;
70+
using type = types<ParameterTypes...>;
7471
};
7572

7673
template<typename ReturnType, typename... ParameterTypes>
7774
struct parameter_type_list<ReturnType (*)(ParameterTypes...)> {
78-
using type = boost::mp11::mp_list<ParameterTypes...>;
75+
using type = types<ParameterTypes...>;
7976
};
8077

8178
template<typename T>
@@ -139,14 +136,14 @@ template<class...>
139136
struct class_declaration_aux;
140137

141138
template<class Policy, class Class, typename... Bases>
142-
struct class_declaration_aux<Policy, boost::mp11::mp_list<Class, Bases...>>
139+
struct class_declaration_aux<Policy, types<Class, Bases...>>
143140
: class_info {
144141
class_declaration_aux() {
145142
this->type = collect_static_type_id<Policy, Class>();
146143
this->first_base =
147-
type_id_list<Policy, boost::mp11::mp_list<Bases...>>::begin;
144+
type_id_list<Policy, types<Bases...>>::begin;
148145
this->last_base =
149-
type_id_list<Policy, boost::mp11::mp_list<Bases...>>::end;
146+
type_id_list<Policy, types<Bases...>>::end;
150147
Policy::classes.push_back(*this);
151148
this->is_abstract = std::is_abstract_v<Class>;
152149
this->static_vptr = &Policy::template static_vptr<Class>;
@@ -159,7 +156,7 @@ struct class_declaration_aux<Policy, boost::mp11::mp_list<Class, Bases...>>
159156

160157
template<typename... Ts>
161158
constexpr auto arity =
162-
boost::mp11::mp_count_if<boost::mp11::mp_list<Ts...>, is_virtual>::value;
159+
boost::mp11::mp_count_if<types<Ts...>, is_virtual>::value;
163160

164161
inline definition_info::~definition_info() {
165162
if (method) {
@@ -171,7 +168,7 @@ template<typename T>
171168
struct is_policy_aux : std::is_base_of<policy::abstract_policy, T> {};
172169

173170
template<typename... T>
174-
struct is_policy_aux<boost::mp11::mp_list<T...>> : std::false_type {};
171+
struct is_policy_aux<types<T...>> : std::false_type {};
175172

176173
template<typename T>
177174
constexpr bool is_policy = is_policy_aux<T>::value;
@@ -340,8 +337,8 @@ constexpr bool is_virtual_ptr = is_virtual_ptr_aux<T>::value;
340337
template<class... Ts>
341338
using virtual_ptr_class = std::conditional_t<
342339
sizeof...(Ts) == 2,
343-
boost::mp11::mp_second<boost::mp11::mp_list<Ts..., void>>,
344-
boost::mp11::mp_first<boost::mp11::mp_list<Ts...>>>;
340+
boost::mp11::mp_second<types<Ts..., void>>,
341+
boost::mp11::mp_first<types<Ts...>>>;
345342

346343
template<class Policy, typename T>
347344
struct argument_traits {
@@ -500,19 +497,19 @@ inline uintptr_t get_tip(const T& arg) {
500497

501498
template<typename... Classes>
502499
using get_policy = std::conditional_t<
503-
is_policy<boost::mp11::mp_back<boost::mp11::mp_list<Classes...>>>,
504-
boost::mp11::mp_back<boost::mp11::mp_list<Classes...>>,
500+
is_policy<boost::mp11::mp_back<types<Classes...>>>,
501+
boost::mp11::mp_back<types<Classes...>>,
505502
YOMM2_DEFAULT_POLICY>;
506503

507504
template<typename... Classes>
508505
using remove_policy = std::conditional_t<
509-
is_policy<boost::mp11::mp_back<boost::mp11::mp_list<Classes...>>>,
510-
boost::mp11::mp_pop_back<boost::mp11::mp_list<Classes...>>,
511-
boost::mp11::mp_list<Classes...>>;
506+
is_policy<boost::mp11::mp_back<types<Classes...>>>,
507+
boost::mp11::mp_pop_back<types<Classes...>>,
508+
types<Classes...>>;
512509

513510
template<class... Ts>
514511
using virtual_ptr_policy = std::conditional_t<
515-
sizeof...(Ts) == 2, boost::mp11::mp_first<boost::mp11::mp_list<Ts...>>,
512+
sizeof...(Ts) == 2, boost::mp11::mp_first<types<Ts...>>,
516513
YOMM2_DEFAULT_POLICY>;
517514

518515
// -----------------------------------------------------------------------------
@@ -526,12 +523,12 @@ template<
526523
typename... SPEC_PARAM>
527524
struct thunk<
528525
Policy, BASE_RETURN(BASE_PARAM...), SPEC,
529-
boost::mp11::mp_list<SPEC_PARAM...>> {
526+
types<SPEC_PARAM...>> {
530527
static BASE_RETURN fn(remove_virtual<BASE_PARAM>... arg) {
531528
using base_type =
532-
boost::mp11::mp_first<boost::mp11::mp_list<BASE_PARAM...>>;
529+
boost::mp11::mp_first<types<BASE_PARAM...>>;
533530
using spec_type =
534-
boost::mp11::mp_first<boost::mp11::mp_list<SPEC_PARAM...>>;
531+
boost::mp11::mp_first<types<SPEC_PARAM...>>;
535532
return SPEC(
536533
argument_traits<Policy, BASE_PARAM>::template cast<SPEC_PARAM>(
537534
remove_virtual<BASE_PARAM>(arg))...);
@@ -563,51 +560,51 @@ struct member_function_thunk<F, R (C::*)(Args...)> {
563560
// base. The direct and its direct and indirect proper bases are included. The
564561
// runtime will extract the direct proper bases. See unit tests for an example.
565562
template<typename... Cs>
566-
using inheritance_map = boost::mp11::mp_list<boost::mp11::mp_push_front<
563+
using inheritance_map = types<boost::mp11::mp_push_front<
567564
boost::mp11::mp_filter_q<
568565
boost::mp11::mp_bind_back<std::is_base_of, Cs>,
569-
boost::mp11::mp_list<Cs...>>,
566+
types<Cs...>>,
570567
Cs>...>;
571568

572569
template<class Policy, class... Classes>
573570
struct use_classes_aux;
574571

575572
template<class Policy, class... Classes>
576-
struct use_classes_aux<Policy, boost::mp11::mp_list<Classes...>> {
573+
struct use_classes_aux<Policy, types<Classes...>> {
577574
using type = boost::mp11::mp_apply<
578575
std::tuple,
579576
boost::mp11::mp_transform_q<
580577
boost::mp11::mp_bind_front<class_declaration_aux, Policy>,
581578
boost::mp11::mp_apply<
582-
inheritance_map, boost::mp11::mp_list<Classes...>>>>;
579+
inheritance_map, types<Classes...>>>>;
583580
};
584581

585582
template<class Policy, class... Classes, class... MoreClassLists>
586583
struct use_classes_aux<
587584
Policy,
588-
boost::mp11::mp_list<boost::mp11::mp_list<Classes...>, MoreClassLists...>>
585+
types<types<Classes...>, MoreClassLists...>>
589586
: use_classes_aux<
590587
Policy,
591588
boost::mp11::mp_append<
592-
boost::mp11::mp_list<Classes...>, MoreClassLists...>>
589+
types<Classes...>, MoreClassLists...>>
593590

594591
{};
595592

596593
template<typename... Ts>
597594
using second_last = boost::mp11::mp_at_c<
598-
boost::mp11::mp_list<Ts...>,
599-
boost::mp11::mp_size<boost::mp11::mp_list<Ts...>>::value - 2>;
595+
types<Ts...>,
596+
boost::mp11::mp_size<types<Ts...>>::value - 2>;
600597

601598
template<class... Classes>
602599
using use_classes_macro = typename std::conditional_t<
603600
is_policy<second_last<Classes...>>,
604601
use_classes_aux<
605602
second_last<Classes...>,
606603
boost::mp11::mp_pop_back<
607-
boost::mp11::mp_pop_back<boost::mp11::mp_list<Classes...>>>>,
604+
boost::mp11::mp_pop_back<types<Classes...>>>>,
608605
use_classes_aux<
609-
boost::mp11::mp_back<boost::mp11::mp_list<Classes...>>,
610-
boost::mp11::mp_pop_back<boost::mp11::mp_list<Classes...>>>>::type;
606+
boost::mp11::mp_back<types<Classes...>>,
607+
boost::mp11::mp_pop_back<types<Classes...>>>>::type;
611608

612609
struct empty_base {};
613610

include/yorel/yomm2/detail/compiler.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,32 @@ struct aggregate_reports;
3636

3737
template<class... Reports, class Facet, class... MoreFacets>
3838
struct aggregate_reports<
39-
boost::mp11::mp_list<Reports...>,
40-
boost::mp11::mp_list<Facet, MoreFacets...>,
39+
types<Reports...>,
40+
types<Facet, MoreFacets...>,
4141
std::void_t<typename Facet::report>> {
4242
using type = typename aggregate_reports<
43-
boost::mp11::mp_list<Reports..., typename Facet::report>,
44-
boost::mp11::mp_list<MoreFacets...>>::type;
43+
types<Reports..., typename Facet::report>,
44+
types<MoreFacets...>>::type;
4545
};
4646

4747
template<class... Reports, class Facet, class... MoreFacets, typename Void>
4848
struct aggregate_reports<
49-
boost::mp11::mp_list<Reports...>,
50-
boost::mp11::mp_list<Facet, MoreFacets...>, Void> {
49+
types<Reports...>,
50+
types<Facet, MoreFacets...>, Void> {
5151
using type = typename aggregate_reports<
52-
boost::mp11::mp_list<Reports...>,
53-
boost::mp11::mp_list<MoreFacets...>>::type;
52+
types<Reports...>,
53+
types<MoreFacets...>>::type;
5454
};
5555

5656
template<class... Reports, typename Void>
5757
struct aggregate_reports<
58-
boost::mp11::mp_list<Reports...>, boost::mp11::mp_list<>, Void> {
58+
types<Reports...>, types<>, Void> {
5959
struct type : Reports... {};
6060
};
6161

6262
template<class Policy>
6363
using report_type = typename aggregate_reports<
64-
boost::mp11::mp_list<update_report>, typename Policy::facets>::type;
64+
types<update_report>, typename Policy::facets>::type;
6565

6666
inline void merge_into(boost::dynamic_bitset<>& a, boost::dynamic_bitset<>& b) {
6767
if (b.size() < a.size()) {
@@ -242,7 +242,7 @@ struct compiler : detail::generic_compiler {
242242
using type_index_type = decltype(Policy::type_index(0));
243243

244244
typename detail::aggregate_reports<
245-
boost::mp11::mp_list<update_report>, typename Policy::facets>::type
245+
detail::types<update_report>, typename Policy::facets>::type
246246
report;
247247

248248
std::unordered_map<type_index_type, class_*> class_map;

include/yorel/yomm2/detail/ostdstream.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <array>
55
#include <cstdio>
6+
#include <charconv>
7+
#include <random>
68

79
namespace yorel {
810
namespace yomm2 {

include/yorel/yomm2/detail/trace.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef YOREL_YOMM2_DETAIL_TRACE_HPP
22
#define YOREL_YOMM2_DETAIL_TRACE_HPP
33

4+
#include <boost/dynamic_bitset.hpp>
5+
46
namespace yorel {
57
namespace yomm2 {
68
namespace detail {

include/yorel/yomm2/detail/types.hpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef YOREL_YOMM2_DETAIL_TYPES_HPP
2+
#define YOREL_YOMM2_DETAIL_TYPES_HPP
3+
4+
#include <cstdint>
5+
#include <limits>
6+
7+
#if defined(YOMM2_SHARED)
8+
#if defined(_MSC_VER)
9+
#if !defined(yOMM2_API_msc)
10+
#define yOMM2_API_msc __declspec(dllimport)
11+
#endif
12+
#endif
13+
#endif
14+
15+
#if !defined(yOMM2_API_gcc)
16+
#define yOMM2_API_gcc
17+
#endif
18+
19+
#if !defined(yOMM2_API_msc)
20+
#define yOMM2_API_msc
21+
#endif
22+
23+
#define yOMM2_API yOMM2_API_gcc yOMM2_API_msc
24+
25+
namespace yorel {
26+
namespace yomm2 {
27+
28+
using type_id = std::uintptr_t;
29+
constexpr type_id invalid_type = (std::numeric_limits<type_id>::max)();
30+
31+
namespace detail {
32+
33+
template<typename... Types>
34+
struct types;
35+
36+
}
37+
} // namespace yomm2
38+
} // namespace yorel
39+
40+
#endif

0 commit comments

Comments
 (0)