Skip to content

Commit 1d99515

Browse files
committed
Type: Extractor
1 parent 9968b79 commit 1d99515

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

modules/Type/Extractor.mpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export module CppUtils.Type.Extractor;
2+
3+
import std;
4+
5+
export namespace CppUtils::Type
6+
{
7+
template<class>
8+
struct Extractor;
9+
10+
template<template<class...> class C, class... Args>
11+
struct Extractor<C<Args...>> final
12+
{
13+
using types = std::tuple<Args...>;
14+
15+
template<class... NewArgs>
16+
using rebind = C<NewArgs...>;
17+
};
18+
19+
static_assert(std::same_as<Extractor<std::vector<char>>::types, std::tuple<char, std::allocator<char>>>);
20+
static_assert(std::same_as<Extractor<std::tuple<char, int>>::types, std::tuple<char, int>>);
21+
22+
static_assert(std::same_as<Extractor<std::vector<char>>::rebind<int>, std::vector<int>>);
23+
static_assert(std::same_as<Extractor<std::tuple<char, int>>::rebind<float, double>, std::tuple<float, double>>);
24+
}

modules/Type/Type.mpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export module CppUtils.Type;
33
export import CppUtils.Type.Callable;
44
export import CppUtils.Type.Concept;
55
export import CppUtils.Type.Enum;
6+
export import CppUtils.Type.Extractor;
67
export import CppUtils.Type.Mapping;
78
export import CppUtils.Type.ObjectMapping;
89
export import CppUtils.Type.MemberFunction;

tests/Type/Callable.mpp

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/UnitTests.mpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export import CppUtils.UnitTests.Thread.ThreadLoop;
5050
export import CppUtils.UnitTests.Thread.ThreadPool;
5151
export import CppUtils.UnitTests.Thread.TryAsync;
5252
export import CppUtils.UnitTests.Thread.UniqueLocker;
53-
export import CppUtils.UnitTests.Type.Callable;
5453
export import CppUtils.UnitTests.Type.Concept;
5554
export import CppUtils.UnitTests.Type.Enum;
5655
export import CppUtils.UnitTests.Type.Mapping;

0 commit comments

Comments
 (0)