Skip to content

Commit 109fdef

Browse files
Merge pull request #16 from mcpplibs/feat-explicit-conversion
Enhance type classification and simplify numeric conversion functions and fix #17
2 parents a484387 + 07c4816 commit 109fdef

36 files changed

+2952
-2187
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
8686
build-windows:
8787
runs-on: windows-latest
88-
timeout-minutes: 20
88+
timeout-minutes: 30
8989
steps:
9090
- name: Checkout
9191
uses: actions/checkout@v4
@@ -96,13 +96,13 @@ jobs:
9696
xmake-version: latest
9797
package-cache: true
9898

99-
- name: Build
99+
- name: Build and test
100100
run: |
101-
xmake f -m release -y -vv
102-
xmake -y -vv -j$env:NUMBER_OF_PROCESSORS
101+
xmake f -m release --ccache=n -y -vv
102+
xmake b -y -vv -j2 primitives_test
103+
xmake run primitives_test
103104
104-
- name: Test
105-
run: xmake run primitives_test
106-
107-
- name: Run examples
108-
run: xmake run basic
105+
- name: Build and run basic example
106+
run: |
107+
xmake b -y -vv -j2 basic
108+
xmake run basic

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ Makefile
5252
# IDE
5353
/.idea
5454
/.cache
55+
/.vscode

src/conversion/conversion.cppm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module;
2+
3+
export module mcpplibs.primitives.conversion;
4+
5+
export import mcpplibs.primitives.conversion.traits;
6+
export import mcpplibs.primitives.conversion.underlying;

src/conversion/traits.cppm

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module;
2+
3+
#include <expected>
4+
#include <optional>
5+
6+
export module mcpplibs.primitives.conversion.traits;
7+
8+
export namespace mcpplibs::primitives::conversion::risk {
9+
10+
enum class kind : unsigned char {
11+
none = 0,
12+
overflow,
13+
underflow,
14+
domain_error,
15+
precision_loss,
16+
sign_loss,
17+
invalid_type_combination,
18+
};
19+
20+
template <typename Value>
21+
struct traits {
22+
kind code = kind::none;
23+
std::optional<Value> source_value{};
24+
std::optional<Value> converted_value{};
25+
};
26+
27+
} // namespace mcpplibs::primitives::conversion::risk
28+
29+
export namespace mcpplibs::primitives::conversion {
30+
31+
template <typename Value>
32+
using cast_result = std::expected<Value, risk::kind>;
33+
34+
} // namespace mcpplibs::primitives::conversion

0 commit comments

Comments
 (0)