HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Namespaces | Macros | Typedefs | Functions
utility.hpp File Reference

Utilities used by the HikoGUI library itself. More...

#include <cstddef>
#include <string>
#include <chrono>

Go to the source code of this file.

Namespaces

namespace  hi
 The HikoGUI namespace.
 
namespace  hi::v1
 The HikoGUI API version 1.
 

Macros

#define hilet   auto const
 Invariant should be the default for variables.
 
#define hi_forward(x)   std::forward<decltype(x)>(x)
 Forward a value, based on the decltype of the value.
 
#define hi_num_va_args_impl(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, N, ...)   N
 
#define hi_num_va_args_(...)   hi_num_va_args_impl(__VA_ARGS__)
 
#define hi_num_va_args(...)
 Get the number of arguments.
 
#define hi_parans   ()
 
#define hi_expand1(...)   __VA_ARGS__
 
#define hi_expand2(...)   hi_expand1(hi_expand1(hi_expand1(hi_expand1(__VA_ARGS__))))
 
#define hi_expand3(...)   hi_expand2(hi_expand2(hi_expand2(hi_expand2(__VA_ARGS__))))
 
#define hi_expand4(...)   hi_expand3(hi_expand3(hi_expand3(hi_expand3(__VA_ARGS__))))
 
#define hi_expand(...)   hi_expand4(hi_expand4(hi_expand4(hi_expand4(__VA_ARGS__))))
 Re-evaluate text up to 256 times by the pre-processor.
 
#define hi_for_each_again()   hi_for_each_helper
 
#define hi_for_each_helper(macro, first_arg, ...)   macro(first_arg) __VA_OPT__(hi_for_each_again hi_parans(macro, __VA_ARGS__))
 
#define hi_for_each(macro, ...)   __VA_OPT__(hi_expand(hi_for_each_helper(macro, __VA_ARGS__)))
 Evaluate a macro for each argument.
 
#define hi_stringify_(x)   #x
 
#define hi_stringify(x)   hi_stringify_(x)
 
#define hi_cat_(a, b)   a##b
 
#define hi_cat(a, b)   hi_cat_(a, b)
 
#define hi_return_on_self_assignment(other)
 
#define hi_get_overloaded_macro2(_1, _2, name, ...)   name
 Get an overloaded macro for 1 or 2 arguments.
 
#define hi_unreachable()   std::terminate()
 
#define hi_assume(condition)   static_assert(sizeof(condition) == 1)
 
#define hi_force_inline   inline
 
#define hi_no_inline
 
#define hi_restrict
 
#define hi_warning_push()
 
#define hi_warning_pop()
 
#define hi_msvc_pragma(a)
 
#define hi_warning_ignore_clang(a)
 
#define msvc_pragma(a)
 
#define hi_typename
 
#define ssizeof(x)   (static_cast<ssize_t>(sizeof(x)))
 

Typedefs

using hi::v1::ssize_t = std::ptrdiff_t
 Signed size/index into an array.
 

Functions

 hi_warning_ignore_msvc (26472)
 
constexpr std::size_t hi::v1::operator""_uz (unsigned long long lhs) noexcept
 
constexpr std::size_t hi::v1::operator""_zu (unsigned long long lhs) noexcept
 
constexpr std::ptrdiff_t hi::v1::operator""_z (unsigned long long lhs) noexcept
 
template<typename T , typename U >
bool hi::v1::compare_store (T &lhs, U &&rhs) noexcept
 Compare then store if there was a change.
 
template<typename T , typename U >
bool hi::v1::compare_store (std::atomic< T > &lhs, U &&rhs) noexcept
 Compare then store if there was a change.
 

Detailed Description

Utilities used by the HikoGUI library itself.

This file includes required definitions.

Macro Definition Documentation

◆ hi_expand

#define hi_expand ( ...)    hi_expand4(hi_expand4(hi_expand4(hi_expand4(__VA_ARGS__))))

Re-evaluate text up to 256 times by the pre-processor.

Parameters
...The text which needs to be re-evaluated by the pre-processor.

◆ hi_for_each

#define hi_for_each ( macro,
... )   __VA_OPT__(hi_expand(hi_for_each_helper(macro, __VA_ARGS__)))

Evaluate a macro for each argument.

Parameters
macroA macro that accepts a single argument.
...A set of arguments to be passed one-by-one to macro.

◆ hi_forward

#define hi_forward ( x)    std::forward<decltype(x)>(x)

Forward a value, based on the decltype of the value.

◆ hi_get_overloaded_macro2

#define hi_get_overloaded_macro2 ( _1,
_2,
name,
... )   name

Get an overloaded macro for 1 or 2 arguments.

This macro allows dispatching to other macros based on the number of arguments.

#define foo1(a) bar(a)
#define foo2(a, b) bar(a, b)
#define foo(...) hi_get_overloaded_macro2(__VA_ARGS__, foo2, foo1)(__VA_ARGS__)

◆ hi_num_va_args

#define hi_num_va_args ( ...)
Value:
hi_num_va_args_(__VA_ARGS__ __VA_OPT__(,) \
63,62,61,60, \
59,58,57,56,55,54,53,52,51,50, \
49,48,47,46,45,44,43,42,41,40, \
39,38,37,36,35,34,33,32,31,30, \
29,28,27,26,25,24,23,22,21,20, \
19,18,17,16,15,14,13,12,11,10, \
9,8,7,6,5,4,3,2,1,0)

Get the number of arguments.

Parameters
...A set of arguments
Returns
The number of arguments pass to this macro.

◆ hi_return_on_self_assignment

#define hi_return_on_self_assignment ( other)
Value:
if (&(other) == this) [[unlikely]] \
return *this;

◆ hilet

#define hilet   auto const

Invariant should be the default for variables.

C++ does have an invariant but it requires you to enter the 'const' keyword which is easy to forget. Using a single keyword 'hilet' for an invariant makes it easier to notice when you have defined a variant.