AsmGrader 0.0.0
Loading...
Searching...
No Matches
cconstexpr.hpp File Reference

constexpr capable functions from c-style headers More...

#include <asmgrader/common/aliases.hpp>
#include <libassert/assert.hpp>
#include <cctype>
#include <cmath>
#include <concepts>
#include <cstdlib>
#include <functional>
#include <limits>
#include <type_traits>
Include dependency graph for cconstexpr.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  asmgrader
 
namespace  asmgrader::detail
 
namespace  asmgrader::detail::cctype
 

Macros

#define CCTYPE_IMPL(name, ret_type)
 

Functions

constexpr bool asmgrader::detail::in_range (auto &&val, auto &&low, auto &&high)
 inclusive
 
template<typename Type >
consteval decltype(auto) asmgrader::detail::resolve_overload (auto &&overloaded)
 
template<typename Ret , typename... ExtraArgs>
consteval auto asmgrader::detail::cctype::make_safe_wrapper (int(&cfunc)(int, ExtraArgs...))
 
constexpr bool asmgrader::detail::cctype::islower (char c)
 
constexpr bool asmgrader::detail::cctype::isupper (char c)
 
constexpr char asmgrader::detail::cctype::tolower (char c)
 
constexpr char asmgrader::detail::cctype::toupper (char c)
 
constexpr bool asmgrader::detail::cctype::isdigit (char c)
 
constexpr bool asmgrader::detail::cctype::isxdigit (char c)
 
constexpr bool asmgrader::detail::cctype::isalpha (char c)
 
constexpr bool asmgrader::detail::cctype::isalnum (char c)
 
constexpr bool asmgrader::detail::cctype::iscntrl (char c)
 
constexpr bool asmgrader::detail::cctype::isgraph (char c)
 
constexpr bool asmgrader::detail::cctype::isprint (char c)
 
constexpr bool asmgrader::detail::cctype::isblank (char c)
 
constexpr bool asmgrader::detail::cctype::isspace (char c)
 
constexpr bool asmgrader::detail::cctype::ispunct (char c)
 
 asmgrader::CCTYPE_IMPL (isdigit, bool)
 
 asmgrader::CCTYPE_IMPL (isxdigit, bool)
 
 asmgrader::CCTYPE_IMPL (islower, bool)
 
 asmgrader::CCTYPE_IMPL (isupper, bool)
 
 asmgrader::CCTYPE_IMPL (isalpha, bool)
 
 asmgrader::CCTYPE_IMPL (isalnum, bool)
 
 asmgrader::CCTYPE_IMPL (iscntrl, bool)
 
 asmgrader::CCTYPE_IMPL (isgraph, bool)
 
 asmgrader::CCTYPE_IMPL (isprint, bool)
 
 asmgrader::CCTYPE_IMPL (isblank, bool)
 
 asmgrader::CCTYPE_IMPL (isspace, bool)
 
 asmgrader::CCTYPE_IMPL (ispunct, bool)
 
 asmgrader::CCTYPE_IMPL (toupper, char)
 
 asmgrader::CCTYPE_IMPL (tolower, char)
 
template<typename T >
requires std::is_arithmetic_v<T>
constexpr T asmgrader::abs (T val)
 
template<typename BaseT , std::unsigned_integral ExpT>
requires std::is_arithmetic_v<BaseT>
constexpr std::common_type_t< BaseT, ExpT > asmgrader::pow (BaseT base, ExpT exp)
 

Detailed Description

constexpr capable functions from c-style headers

All functions in this file will fall back to the c-style implementations when not in a constant-evaluated context, so runtime performance is guaranteed to be at least as good. Also fixes UB issues with cctype functions.

Refer to the cppreference page on std lib headers for the pages I used as authoritative definitions in implementing these functions.

Macro Definition Documentation

◆ CCTYPE_IMPL

#define CCTYPE_IMPL ( name,
ret_type )
Value:
constexpr ret_type name(char c) { \
if (std::is_constant_evaluated()) { \
return detail::cctype::name(c); \
} \
return detail::cctype::make_safe_wrapper<ret_type>(std::name)(c); \
}