Skip to content

Commit

Permalink
Workaround broken std::source_location in Clang 15
Browse files Browse the repository at this point in the history
  • Loading branch information
hasselmm committed Dec 20, 2023
1 parent 7edfeef commit fcd3444
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions mproperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@

#include <utility>

#if defined(Q_CC_CLANG) && Q_CC_CLANG < 1600
#define CURRENT_LINE_NUMBER() __builtin_LINE()
#else
#define CURRENT_LINE_NUMBER() std::source_location::current().line()
#endif

namespace mproperty {
namespace Private {


} // namespace Private

enum class Feature
Expand Down Expand Up @@ -454,10 +459,9 @@ class Object : public BaseObjectType
}

protected:
static consteval std::size_t n(const std::source_location &source =
std::source_location::current())
static constexpr std::size_t n(std::size_t l = CURRENT_LINE_NUMBER()) noexcept
{
return source.line();
return l;
}
};

Expand All @@ -467,7 +471,8 @@ class Object : public BaseObjectType
\
public: \
static const MetaObject staticMetaObject; \
int qt_metacall(QMetaObject::Call call, int offset, void **args) override;
int qt_metacall(QMetaObject::Call call, int offset, void **args) override; \
static_assert(n() == __LINE__);

#define M_OBJECT_IMPLEMENTATION(ClassName, ...) \
\
Expand Down

0 comments on commit fcd3444

Please sign in to comment.