From 9804a26cb43a63649c91d6fa22f3daab06113b86 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 18 Jan 2023 18:19:45 +0800 Subject: [PATCH] feat: allow direct conversion without `unwrap` --- src/common_code/common_code.h | 1 + src/main.cc | 4 ++-- src/raw_code/raw_code.h | 1 + src/short_code/short_code.h | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common_code/common_code.h b/src/common_code/common_code.h index dd5c6e3..1f4e502 100644 --- a/src/common_code/common_code.h +++ b/src/common_code/common_code.h @@ -12,6 +12,7 @@ class ShortCode; class CommonCode { public: static bool check(uint64_t common_code); + explicit operator uint64_t() const { return code; } friend std::ostream& operator<<(std::ostream &out, const CommonCode &self); /// Export functions diff --git a/src/main.cc b/src/main.cc index d7cbf3c..56b7a55 100644 --- a/src/main.cc +++ b/src/main.cc @@ -15,7 +15,7 @@ int main() { - BasicRanges::build(); +// BasicRanges::build(); // std::cout << "wait 3s" << std::endl; // sleep(3); @@ -26,7 +26,7 @@ int main() { // AllCases::build(); auto f = FastCal(); - auto ret = f.solve(RawCode::from_common_code("1a9bf0c").unwrap()); + auto ret = f.solve((uint64_t)RawCode::from_common_code("1a9bf0c")); // auto f = FastCal(RawCode::from_common_code("1a9bf0c").unwrap()); // auto ret = f.solve(); diff --git a/src/raw_code/raw_code.h b/src/raw_code/raw_code.h index fdc8613..65a7907 100644 --- a/src/raw_code/raw_code.h +++ b/src/raw_code/raw_code.h @@ -10,6 +10,7 @@ class CommonCode; class RawCode { public: static bool check(uint64_t raw_code); + explicit operator uint64_t() const { return code; } friend std::ostream& operator<<(std::ostream &out, const RawCode &self); /// Export functions diff --git a/src/short_code/short_code.h b/src/short_code/short_code.h index ca26a44..3eea502 100644 --- a/src/short_code/short_code.h +++ b/src/short_code/short_code.h @@ -15,6 +15,7 @@ public: static void speed_up(enum Mode mode); static bool check(uint32_t short_code); + explicit operator uint32_t() const { return code; } friend std::ostream& operator<<(std::ostream &out, const ShortCode &self); /// Export functions