Skip to content

Commit

Permalink
Function like macros to avoid typos
Browse files Browse the repository at this point in the history
  • Loading branch information
gracicot committed Dec 19, 2023
1 parent a8d5f49 commit ce49627
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
8 changes: 4 additions & 4 deletions include/kangaru/detail/deducer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ namespace kangaru {
template<deducible T>
operator T& () const;

#if KANGARU5_LVALUE_CONST_AMBIGUOUS == 1
#if KANGARU5_LVALUE_CONST_AMBIGUOUS() == 1
template<deducible T>
operator T const& () const;
#endif

#if KANGARU5_RVALUE_AMBIGUOUS == 1
#if KANGARU5_RVALUE_AMBIGUOUS() == 1
template<typename T>
operator T&& () const;
#endif
Expand All @@ -93,12 +93,12 @@ namespace kangaru {
template<deducible T>
operator T& ();

#if KANGARU5_LVALUE_CONST_AMBIGUOUS == 1
#if KANGARU5_LVALUE_CONST_AMBIGUOUS() == 1
template<deducible T>
operator T const& ();
#endif

#if KANGARU5_RVALUE_AMBIGUOUS == 1
#if KANGARU5_RVALUE_AMBIGUOUS() == 1
template<typename T>
operator T&& ();
#endif
Expand Down
42 changes: 17 additions & 25 deletions include/kangaru/detail/define.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
#define KANGARU5_DETAIL_DEFINE_HPP

#if defined(_MSC_VER) && !defined(__clang__)
#define KANGARU5_IS_MSVC 1
#define KANGARU5_IS_MSVC() 1
#else
#define KANGARU5_IS_MSVC 0
#define KANGARU5_IS_MSVC() 0
#endif

#if defined(__GNUC__) && !defined(__clang__)
#define KANGARU5_IS_GNU 1
#define KANGARU5_IS_GNU() 1
#else
#define KANGARU5_IS_GNU 0
#define KANGARU5_IS_GNU() 0
#endif

#if defined(__clang__)
#define KANGARU5_IS_CLANG 1
#define KANGARU5_IS_CLANG() 1
#else
#define KANGARU5_IS_CLANG 0
#define KANGARU5_IS_CLANG() 0
#endif

#if KANGARU5_IS_MSVC == 1
#if KANGARU5_IS_MSVC() == 1
#define KANGARU5_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
#else
#define KANGARU5_NO_UNIQUE_ADDRESS [[no_unique_address]]
#endif

#if KANGARU_IS_MSVC == 1
#if KANGARU5_IS_MSVC() == 1
#define KANGARU5_FUNCTION_SIGNATURE __FUNCSIG__
#else
#define KANGARU5_FUNCTION_SIGNATURE __PRETTY_FUNCTION__
Expand All @@ -34,30 +34,22 @@
#define KANGARU5_FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
#define KANGARU5_CONSTRUCTOR_T(...) decltype(::kangaru::constructor<__VA_ARGS__>())

#if KANGARU5_IS_CLANG == 1
#if KANGARU5_IS_CLANG() == 1
#define KANGARU5_INLINE [[gnu::always_inline]]
#define KANGARU5_RVALUE_AMBIGUOUS 0
#define KANGARU5_LVALUE_CONST_AMBIGUOUS 1
#define KANGARU5_RVALUE_AMBIGUOUS() 0
#define KANGARU5_LVALUE_CONST_AMBIGUOUS() 1
#endif

#if KANGARU5_IS_GNU == 1
#if KANGARU5_IS_GNU() == 1
#define KANGARU5_INLINE [[gnu::always_inline]]
#define KANGARU5_RVALUE_AMBIGUOUS 1
#define KANGARU5_LVALUE_CONST_AMBIGUOUS 0
#define KANGARU5_RVALUE_AMBIGUOUS() 1
#define KANGARU5_LVALUE_CONST_AMBIGUOUS() 0
#endif

#if KANGARU5_IS_MSVC == 1
#if KANGARU5_IS_MSVC() == 1
#define KANGARU5_INLINE [[msvc::forceinline]]
#define KANGARU5_RVALUE_AMBIGUOUS 0
#define KANGARU5_LVALUE_CONST_AMBIGUOUS 1
#endif

// #define KANGARU5_DEBUG_SKIP_PRVALUE_PREPASS

#ifdef KANGARU5_DEBUG_SKIP_PRVALUE_PREPASS
#define KANGARU5_SKIP_PRVALUE_PREPASS 1
#else
#define KANGARU5_SKIP_PRVALUE_PREPASS 0
#define KANGARU5_RVALUE_AMBIGUOUS() 0
#define KANGARU5_LVALUE_CONST_AMBIGUOUS() 1
#endif

#undef KANGARU5_IS_MSVC
Expand Down

0 comments on commit ce49627

Please sign in to comment.