jaulib v1.5.0
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
cpp_lang_util.hpp File Reference
#include <climits>
#include <cstdint>
#include <string_view>
#include <type_traits>
#include <exception>
#include <string>
#include <cstring>
#include <ostream>
#include <jau/packed_attribute.hpp>
Include dependency graph for cpp_lang_util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  jau::has_builtin_bit_cast_t< Dummy_type >
 Convenience type trait for __has_builtin(__builtin_bit_cast). More...
 
struct  jau::Int64SizeBoolTuple
 Simple pre-defined value tuple [int64_t, size_t, bool] for structured bindings to multi-values. More...
 
struct  jau::SizeBoolPair
 Simple pre-defined value pair [size_t, bool] for structured bindings to multi-values. More...
 
struct  jau::UInt64SizeBoolTuple
 Simple pre-defined value tuple [uint64_t, size_t, bool] for structured bindings to multi-values. More...
 
struct  jau::UInt8PtrSizeBoolPair
 Simple pre-defined value pair [uint8_t*, size_t, bool] for structured bindings to multi-values. More...
 

Namespaces

namespace  jau
 __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
 

Macros

#define __attrdecl_no_optimize__
 
#define __attrdef_no_optimize__
 
#define __restrict_cxx__
 Wrap C++ extension __restrict__ covering C99's restrict feature keyword.
 
#define consteval_cxx20   constexpr
 consteval qualifier replacement for C++20 consteval.
 
#define constexpr_atomic   constexpr_cxx23
 Used when designed to declare a function constexpr, but prohibited by its specific implementation.
 
#define constexpr_cxx20   inline
 constexpr qualifier replacement for C++20 constexpr.
 
#define constexpr_cxx23   inline
 
#define constexpr_cxx26   inline
 
#define constexpr_non_literal_var   constexpr_cxx23
 Used when designed to declare a function constexpr, but prohibited by its specific implementation.
 
#define constinit_cxx20   constexpr
 constinit qualifier replacement for C++20 constinit.
 
#define E_FILE_LINE   __FILE__, __LINE__
 
#define final_opt   final
 Optional generic usage of final keyword w/o negative performance impact.
 
#define JAU_DECLTYPE_VALUE(type)
 
#define JAU_EXPAND(...)
 
#define JAU_EXPAND1(...)
 
#define JAU_EXPAND2(...)
 
#define JAU_EXPAND3(...)
 
#define JAU_EXPAND4(...)
 
#define JAU_FOR_EACH1_LIST(macro, ...)
 
#define JAU_FOR_EACH1_LIST_AGAIN()
 
#define JAU_FOR_EACH1_LIST_HELPER(macro, a1, ...)
 
#define JAU_FOR_EACH2(macro, type, ...)
 
#define JAU_FOR_EACH2_AGAIN()
 
#define JAU_FOR_EACH2_HELPER(macro, type, a1, ...)
 
#define JAU_FOR_EACH2_LIST(macro, type, ...)
 
#define JAU_FOR_EACH2_LIST_AGAIN()
 
#define JAU_FOR_EACH2_LIST_HELPER(macro, type, a1, ...)
 
#define JAU_FOR_EACH2_VALUE(macro, type, value, ...)
 
#define JAU_FOR_EACH2_VALUE_AGAIN()
 
#define JAU_FOR_EACH2_VALUE_HELPER(macro, type, value, a1, ...)
 
#define JAU_NOREF_DECLTYPE_VALUE(type)
 
#define JAU_PARENS   ()
 

Enumerations

enum class  jau::Bool : bool { jau::Bool::False = false , jau::Bool::True = true }
 Boolean type without implicit conversion, safe for function parameter. More...
 

Functions

template<class Dest, class Source>
constexpr std::enable_if_t< sizeof(Dest)==sizeof(Source) &&std::is_trivially_copyable_v< Dest > &&std::is_trivially_copyable_v< Source >, Dest > jau::bit_cast (const Source &src) noexcept
 C++20 bit_cast<>(arg) implementation for C++17.
 
template<typename UnaryFunc>
void jau::callNotOptimize (UnaryFunc f) __attrdef_no_optimize__
 Simple unary function wrapper which ensures function call to happen in order and not optimized away.
 
consteval_cxx20 void jau::consteval_assert (bool v)
 
std::string jau::demangle_name (const char *mangled_name) noexcept
 Returns the demangled given mangled_name if successful, otherwise the mangled_name.
 
template<class UnaryPredicate>
bool jau::do_noexcept (UnaryPredicate p) noexcept
 No throw wrap for given unary predicate p action. Returns true for success (no exception), otherwise false (exception occurred).
 
constexpr Bool jau::False () noexcept
 
bool jau::handle_exception (std::exception_ptr eptr, const char *file, int line) noexcept
 Handle given optional exception (nullable std::exception_ptr) and send std::exception::what() message to stderr
 
consteval_cxx20 bool jau::has_builtin_bit_cast () noexcept
 Query whether __builtin_bit_cast(Dest_type, arg) is available via __has_builtin(__builtin_bit_cast).
 
consteval_cxx20 bool jau::is_builtin_int128_available () noexcept
 
consteval_cxx20 bool jau::is_cxx17 () noexcept
 Returns true if compiled with >= C++17.
 
consteval_cxx20 bool jau::is_cxx20 () noexcept
 Returns true if compiled with >= C++20.
 
consteval_cxx20 bool jau::is_cxx23 () noexcept
 Returns true if compiled with >= C++23.
 
consteval_cxx20 bool jau::is_cxx26 () noexcept
 Returns true if compiled with >= C++26.
 
consteval_cxx20 bool jau::is_debug_enabled () noexcept
 Returns true if compiled with debug information and w/o optimization, i.e.
 
constexpr Bool jau::makeBool (bool v) noexcept
 
constexpr std::string_view jau::name (const Bool v) noexcept
 
constexpr Bool jau::operator! (const Bool rhs) noexcept
 
constexpr Bool jau::operator& (const Bool lhs, const Bool rhs) noexcept
 
constexpr Bool jau::operator&& (const Bool lhs, const Bool rhs) noexcept
 
constexpr Booljau::operator&= (Bool &lhs, const Bool rhs) noexcept
 
constexpr bool jau::operator* (const Bool rhs) noexcept
 
std::ostream & jau::operator<< (std::ostream &out, const Bool c)
 
constexpr bool jau::operator== (const Bool lhs, const Bool rhs) noexcept
 
constexpr Bool jau::operator^ (const Bool lhs, const Bool rhs) noexcept
 
constexpr Booljau::operator^= (Bool &lhs, const Bool rhs) noexcept
 
constexpr Bool jau::operator| (const Bool lhs, const Bool rhs) noexcept
 
constexpr Booljau::operator|= (Bool &lhs, const Bool rhs) noexcept
 
constexpr Bool jau::operator|| (const Bool lhs, const Bool rhs) noexcept
 
template<class Dest, class Source>
constexpr std::enable_if_t< sizeof(Dest)==sizeof(Source) &&std::is_pointer_v< Source > &&std::is_pointer_v< Dest >, Dest > jau::pointer_cast (const Source &src) noexcept
 A constexpr pointer cast implementation for C++17, inspired by C++20 bit_cast<>(arg).
 
std::string jau::string_noexcept (std::string_view v) noexcept
 No throw std::string(std::string_view) instantiation.
 
template<class UnaryPredicate>
std::string jau::string_noexcept (UnaryPredicate p) noexcept
 No throw wrap for given unary predicate p producing a std::string. Returns an empty string if p causes an exception.
 
std::string jau::to_string (const Bool v) noexcept
 
constexpr Bool jau::True () noexcept
 
constexpr bool jau::value (const Bool rhs) noexcept
 

Variables

template<typename Dummy_type>
constexpr bool jau::has_builtin_bit_cast_v = has_builtin_bit_cast_t<Dummy_type>::value
 Value access of has_builtin_bit_cast type trait for convenience .