-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove matchit dependency for users. (#60)
* Remove matchit dependency for users. * Fix build. Co-authored-by: Bowen Fu <missing>
- Loading branch information
Showing
12 changed files
with
91 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include "mathiu/core.h" | ||
#include "matchit.h" | ||
#include "internal.h" | ||
#include <numeric> | ||
|
||
namespace mathiu::impl | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include "matchit.h" | ||
#include "mathiu/core.h" | ||
#include "internal.h" | ||
#include "mathiu/diff.h" | ||
#include <numeric> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#ifndef INTERNAL_H | ||
#define INTERNAL_H | ||
|
||
#include "mathiu/core.h" | ||
#include "matchit.h" | ||
|
||
#define VERBOSE_DEBUG 0 | ||
#define DEBUG 1 | ||
|
||
#if DEBUG | ||
#include <iostream> | ||
#endif // DEBUG | ||
|
||
namespace matchit::impl | ||
{ | ||
template <> | ||
class PatternTraits<mathiu::impl::ExprPtr> | ||
{ | ||
using Pattern = mathiu::impl::ExprPtr; | ||
public: | ||
template <typename Value> | ||
using AppResultTuple = std::tuple<>; | ||
|
||
constexpr static auto nbIdV = 0; | ||
|
||
template <typename Value, typename ContextT> | ||
constexpr static auto matchPatternImpl(Value &&value, Pattern const &pattern, | ||
int32_t /* depth */, | ||
ContextT & /*context*/) | ||
{ | ||
return mathiu::impl::equal(pattern, std::forward<Value>(value)); | ||
} | ||
constexpr static void processIdImpl(Pattern const &, int32_t /*depth*/, | ||
IdProcess) {} | ||
}; | ||
|
||
template <> | ||
class IdTraits<mathiu::impl::ExprPtr> | ||
{ | ||
using Type = mathiu::impl::ExprPtr; | ||
public: | ||
static auto | ||
#if defined(__has_feature) | ||
#if __has_feature(address_sanitizer) | ||
__attribute__((no_sanitize_address)) | ||
#endif | ||
#endif | ||
equal(Type const &lhs, Type const &rhs) | ||
{ | ||
return mathiu::impl::equal(lhs, rhs); | ||
} | ||
}; | ||
|
||
} // namespace matchit::impl | ||
|
||
namespace mathiu | ||
{ | ||
namespace impl | ||
{ | ||
inline constexpr auto isRational = matchit::or_(matchit::as<int>(matchit::_), matchit::as<Fraction>(matchit::_)); | ||
|
||
|
||
inline auto const asDouble = matchit::meet([](auto&& e) | ||
{ | ||
try{ | ||
evald(e); | ||
return true; | ||
} | ||
catch (...) | ||
{ | ||
return false; | ||
} | ||
}); | ||
|
||
} // namespace impl | ||
} // namespace mathiu | ||
|
||
#endif // INTERNAL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "mathiu.h" | ||
#include "matchit.h" | ||
#include "gtest/gtest.h" | ||
#include <string> | ||
using namespace mathiu; | ||
|