Skip to content

Commit

Permalink
Removed duplicated code from hex.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Jan 2, 2021
1 parent 78ef07c commit 18c9340
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 48 deletions.
7 changes: 7 additions & 0 deletions plugins/libimhex/include/helpers/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ namespace hex {
#define TOKEN_CONCAT_IMPL(x, y) x ## y
#define TOKEN_CONCAT(x, y) TOKEN_CONCAT_IMPL(x, y)

template<>
struct std::is_integral<u128> : public std::true_type { };
template<>
struct std::is_integral<s128> : public std::true_type { };
template<>
struct std::is_signed<s128> : public std::true_type { };

namespace hex {

template<typename ... Args>
Expand Down
48 changes: 0 additions & 48 deletions plugins/libimhex/include/hex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,4 @@ extern char **mainArgv;
#define MAGIC_PATH_SEPARATOR ";"
#else
#define MAGIC_PATH_SEPARATOR ":"
#endif

template<>
struct std::is_integral<u128> : public std::true_type { };
template<>
struct std::is_integral<s128> : public std::true_type { };
template<>
struct std::is_signed<s128> : public std::true_type { };

#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 12000
#if __has_include(<concepts>)
// Make sure we break when derived_from is implemented in libc++. Then we can fix a compatibility version above
#include <concepts>
#endif
// libcxx 12 still doesn't have many default concepts implemented, as a result we need to define it ourself using clang built-ins.
// [concept.derived] (patch from https://reviews.llvm.org/D74292)
namespace hex {
template<class _Dp, class _Bp>
concept derived_from =
__is_base_of(_Bp, _Dp) && __is_convertible_to(const volatile _Dp*, const volatile _Bp*);
}

// [concepts.arithmetic] (patch from https://reviews.llvm.org/D88131)
namespace hex {
template<class _Tp>
concept integral = __is_integral(_Tp);

template<class _Tp>
concept signed_integral = integral<_Tp> && __is_signed(_Tp);

template<class _Tp>
concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;

template<class _Tp>
concept floating_point = __is_floating_point(_Tp);
}
#else
// Assume supported
#include <concepts>

namespace hex {
using std::derived_from;

using std::integral;
using std::signed_integral;
using std::unsigned_integral;
using std::floating_point;
}
#endif

0 comments on commit 18c9340

Please sign in to comment.