6#ifndef EGT_DETAIL_META_H
7#define EGT_DETAIL_META_H
16#include <egt/detail/math.h>
24# define egt_likely(x) __builtin_expect((x), 1)
28# define egt_unlikely(x) __builtin_expect((x), 0)
31#if defined _WIN32 || defined __CYGWIN__
32# define EGT_HELPER_DLL_IMPORT __declspec(dllimport)
33# define EGT_HELPER_DLL_EXPORT __declspec(dllexport)
34# define EGT_HELPER_DLL_LOCAL
37# define EGT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
38# define EGT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
39# define EGT_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden")))
41# define EGT_HELPER_DLL_IMPORT
42# define EGT_HELPER_DLL_EXPORT
43# define EGT_HELPER_DLL_LOCAL
56# ifdef EGT_DLL_EXPORTS
57# define EGT_API EGT_HELPER_DLL_EXPORT
59# define EGT_API EGT_HELPER_DLL_IMPORT
61# define EGT_LOCAL EGT_HELPER_DLL_LOCAL
68# define EGT_DEPRECATED [[deprecated]]
69# ifdef __has_cpp_attribute
70# define EGT_HAVE_ATTRIBUTE(x) __has_cpp_attribute(x)
72# define EGT_HAVE_ATTRIBUTE(x) 0
74# if EGT_HAVE_ATTRIBUTE(nodiscard) && !defined(__clang__)
75# define EGT_NODISCARD [[nodiscard]]
76# elif EGT_HAVE_ATTRIBUTE(warn_unused_result)
77# define EGT_NODISCARD __attribute__((warn_unused_result))
82# define EGT_DEPRECATED
116 EGT_NODISCARD
auto begin() const -> decltype(this->m_x.rbegin())
122 EGT_NODISCARD
auto end() const -> decltype(this->m_x.rend())
170constexpr
bool rule_of_5()
172 static_assert(std::is_destructible<T>::value,
"must be destructible");
173 static_assert(std::is_copy_constructible<T>::value,
"must be copy constructible");
174 static_assert(std::is_move_constructible<T>::value,
"must be move constructible");
175 static_assert(std::is_copy_assignable<T>::value,
"must be copy assignable");
176 static_assert(std::is_move_assignable<T>::value,
"must be move assignable");
178 return std::is_destructible<T>::value && std::is_copy_constructible<T>::value
179 && std::is_move_constructible<T>::value && std::is_copy_assignable<T>::value
180 && std::is_move_assignable<T>::value;
212 if (!detail::float_equal(old, to))
228 if (!detail::float_equal(old, to))
266 : m_f(std::move(other.m_f)),
267 m_active(other.m_active)
269 other.m_active =
false;
Utility base class to make a derived class non-copy-able.
Definition meta.h:150
NonCopyable(const NonCopyable &)=delete
NonCopyable(NonCopyable &&) noexcept=default
NonCopyable & operator=(const NonCopyable &)=delete
Range class to work with C++11 range based for loops in a reverse order.
Definition meta.h:107
ReverseRange(T &x)
Definition meta.h:113
EGT_NODISCARD auto begin() const -> decltype(this->m_x.rbegin())
begin iterator
Definition meta.h:116
EGT_NODISCARD auto end() const -> decltype(this->m_x.rend())
end iterator
Definition meta.h:122
ReverseRange< T > reverse_iterate(T &x)
Reverse iterator to work with C++11 range based for loops in a reverse order.
Definition meta.h:139
constexpr bool change_if_diff(T &old, const T &to)
Utility to test and change a value if it is different.
Definition meta.h:194
constexpr T bit(T n)
Utility to create a bit mask for the specified bit.
Definition meta.h:306
void ignoreparam(T &&)
Utility function to safely ignore a parameter to a function.
Definition meta.h:97
ScopeExit< T > on_scope_exit(T &&f)
Helper to construct a ScopeExit with proper type deduction of the template parameter,...
Definition meta.h:295
EGT framework namespace.
Definition animation.h:24
Utility to run a callback when this object goes out of scope.
Definition meta.h:245
ScopeExit & operator=(ScopeExit &&)=delete
ScopeExit(const T &f) noexcept
Definition meta.h:259
ScopeExit(ScopeExit &&other) noexcept
Move constructor.
Definition meta.h:265
T m_f
Callback function.
Definition meta.h:285
~ScopeExit()
Definition meta.h:277
bool m_active
Used to manage move.
Definition meta.h:287
ScopeExit & operator=(const ScopeExit &)=delete
ScopeExit(const ScopeExit &)=delete
ScopeExit(T &&f) noexcept
Definition meta.h:250