kblib 0.2.3
General utilities library for modern C++
fakestd.h File Reference

This header provides some features of C++17 <type_traits> and other headers for C++14, as well as some other traits. More...

#include "tdecl.h"
#include <array>
#include <limits>
#include <memory>
#include <type_traits>
#include <utility>
Include dependency graph for fakestd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kblib::fakestd::detail::invoke_result< AlwaysVoid, typename,... >
 
struct  kblib::fakestd::detail::invoke_result< decltype(void(invoke(std::declval< F >(), std::declval< Args >()...))), F, Args... >
 
struct  kblib::fakestd::invoke_result< F, ArgTypes >
 
struct  kblib::fakestd::make_void< Ts >
 
struct  kblib::fakestd::detail::nat
 
struct  kblib::fakestd::detail::two
 
struct  kblib::fakestd::detail::is_referenceable_impl
 
struct  kblib::fakestd::detail::is_referenceable< Tp >
 
struct  kblib::fakestd::detail::swappable_with< Tp, Up, NotVoid >
 
struct  kblib::fakestd::detail::swappable_with< Tp, Up, false >
 
struct  kblib::fakestd::detail::nothrow_swappable_with< Tp, Up, Swappable >
 
struct  kblib::fakestd::detail::nothrow_swappable_with< Tp, Up, false >
 
struct  kblib::fakestd::is_swappable< Tp >
 
struct  kblib::fakestd::is_nothrow_swappable< Tp >
 
struct  kblib::fakestd::is_swappable_with< Tp, Up >
 
struct  kblib::fakestd::is_nothrow_swappable_with< Tp, Up >
 
struct  kblib::fakestd::detail::not_fn_t< F >
 
struct  kblib::fakestd::in_place_t
 
struct  kblib::fakestd::detail::invokable_r< Ret, Fp, Args >
 
struct  kblib::fakestd::detail::nothrow_invokable_r_imp< IsInvokable, IsCVVoid, Ret, Fp, Args >
 
struct  kblib::fakestd::detail::nothrow_invokable_r_imp< true, false, Ret, Fp, Args... >
 
struct  kblib::fakestd::detail::nothrow_invokable_r_imp< true, true, Ret, Fp, Args... >
 
struct  kblib::fakestd::detail::invoke_of< Fp, Args >
 
struct  kblib::fakestd::is_invocable< Fn, Args >
 
struct  kblib::fakestd::is_invocable_r< Ret, Fn, Args >
 
struct  kblib::fakestd::is_nothrow_invocable< Fn, Args >
 
struct  kblib::fakestd::is_nothrow_invocable_r< Ret, Fn, Args >
 
struct  kblib::meta_type< Ts >
 
struct  kblib::meta_type< T >
 
struct  kblib::void_if< bool >
 
struct  kblib::void_if< true >
 
struct  kblib::metafunction_success< T, typename >
 
struct  kblib::metafunction_success< T, void_t< typename T::type > >
 
struct  kblib::is_callable< T >
 
struct  kblib::return_assert< V, T >
 Essentially just like std::enable_if, but with a different name that makes it clearer what it does in the context of return type SFINAE. More...
 
struct  kblib::return_assert< true, T >
 
struct  kblib::detail::apply_impl< F, Arg, typename >
 
struct  kblib::has_member_swap< T >
 
struct  kblib::is_tuple_like< T, typename >
 
struct  kblib::is_tuple_like< T, void_t< typename std::tuple_element< 0, T >::type > >
 
struct  kblib::detail::type_list< Args >
 
struct  kblib::detail::type_map_el< K, V >
 
struct  kblib::detail::type_map< Key, Comp, Vals >
 
struct  kblib::detail::next_larger_signed< T >
 
struct  kblib::detail::next_larger_signed< T >::false_compare
 
struct  kblib::detail::filter_signed< N, true >
 
struct  kblib::detail::filter_unsigned< N, true >
 
struct  kblib::safe_signed< N, std::enable_if_t< std::is_integral< N >::value, void > >
 
struct  kblib::copy_const< C, T, bool >
 
struct  kblib::copy_const< C, T, true >
 
struct  kblib::copy_const< C, T &, true >
 
struct  kblib::copy_const< C, T &&, true >
 
struct  kblib::value_detected< T, typename >
 
struct  kblib::value_detected< T, void_t< typename T::value_type > >
 
struct  kblib::key_detected< T, typename >
 
struct  kblib::key_detected< T, void_t< typename T::key_type > >
 
struct  kblib::mapped_detected< T, typename >
 
struct  kblib::mapped_detected< T, void_t< typename T::mapped_type > >
 
struct  kblib::hash_detected< T, typename >
 
struct  kblib::hash_detected< T, void_t< typename T::hasher > >
 
struct  kblib::value_type_linear< Container, bool, T >
 
struct  kblib::value_type_linear< Container, false, typename Container::value_type >
 
struct  kblib::is_linear_container< Container >
 
struct  kblib::key_type_setlike< Container, bool, bool >
 
struct  kblib::key_type_setlike< Container, true, false >
 
struct  kblib::detail::pointer< D, T, typename >
 
struct  kblib::detail::pointer< D, T, void_t< typename D::pointer > >
 
struct  kblib::in_place_agg_t
 
class  kblib::heap_value< T >
 
class  kblib::heap_value2< T, D >
 
class  kblib::heap_value2< T[], D >
 

Namespaces

namespace  kblib
 The main namespace in which all entities from kblib are defined.
 
namespace  kblib::detail
 The namespace used for implementation details within kblib.
 
namespace  kblib::fakestd
 A namespace which holds all the C++14 implementations of C++17 standard library features. In C++17, it is simply defined as an alias to std.
 
namespace  kblib::fakestd::detail
 Implementation details for kblib::fakestd features.
 

Macros

#define KBLIB_FAKESTD   (__cplusplus < 201703L)
 

Typedefs

template<bool B, typename T = void>
using kblib::enable_if_t = typename std::enable_if< B, T >::type
 
template<typename T >
using kblib::decay_t = typename std::decay< T >::type
 
template<typename T >
using kblib::remove_cvref_t = typename std::remove_reference< typename std::remove_cv< T >::type >::type
 
template<bool v>
using kblib::bool_constant = std::integral_constant< bool, v >
 
template<typename F , typename... ArgTypes>
using kblib::fakestd::invoke_result_t = typename invoke_result< F, ArgTypes... >::type
 
template<typename... Ts>
using kblib::fakestd::void_t = typename make_void< Ts... >::type
 
template<class Fp , class... Args>
using kblib::fakestd::detail::invokable = invokable_r< void, Fp, Args... >
 
template<class Ret , class Fp , class... Args>
using kblib::fakestd::detail::nothrow_invokable_r = nothrow_invokable_r_imp< invokable_r< Ret, Fp, Args... >::value, std::is_void< Ret >::value, Ret, Fp, Args... >
 
template<class Fp , class... Args>
using kblib::fakestd::detail::nothrow_invokable = nothrow_invokable_r_imp< invokable< Fp, Args... >::value, true, void, Fp, Args... >
 
template<typename... Ts>
using kblib::meta_type_t = typename meta_type< Ts... >::type
 
template<bool b>
using kblib::void_if_t = typename void_if< b >::type
 
template<typename T >
using kblib::metafunction_value_t = std::integral_constant< decltype(T::value), T::value >
 
template<bool V, typename T >
using kblib::return_assert_t = typename return_assert< V, T >::type
 
template<typename N >
using kblib::detail::make_smap_el = type_map_el< static_cast< std::intmax_t >(msb_possible< N >()), N >
 
template<typename N >
using kblib::detail::filter_signed_t = typename filter_signed< N >::type
 
template<typename N >
using kblib::detail::filter_unsigned_t = typename filter_unsigned< N >::type
 
template<typename N >
using kblib::safe_signed_t = typename safe_signed< N >::type
 
template<typename C , typename V >
using kblib::copy_const_t = typename copy_const< C, V >::type
 
template<typename T >
using kblib::value_detected_t = typename value_detected< T >::type
 
template<typename T >
using kblib::key_detected_t = typename key_detected< T >::type
 
template<typename T >
using kblib::mapped_detected_t = typename mapped_detected< T >::type
 
template<typename T >
using kblib::hash_detected_t = typename hash_detected< T >::type
 
template<typename Container >
using kblib::value_type_linear_t = typename value_type_linear< Container >::type
 
template<typename Container >
using kblib::key_type_setlike_t = typename key_type_setlike< Container >::type
 

Functions

template<typename F , typename... Args, enable_if_t< not std::is_member_pointer< remove_cvref_t< F > >::value, int > = 0>
constexpr auto kblib::detail::do_invoke (F &&f, Args &&... args) noexcept(noexcept(std::forward< F >(f)(std::forward< Args >(args)...))) -> decltype(auto)
 
template<typename F , typename Object , typename... Args, enable_if_t< not std::is_pointer< remove_cvref_t< Object > >::value and std::is_member_function_pointer< F >::value, int > = 0>
constexpr auto kblib::detail::do_invoke (F f, Object &&obj, Args &&... args) noexcept(noexcept((std::forward< Object >(obj).*f)(std::forward< Args >(args)...))) -> decltype(auto)
 
template<typename F , typename Pointer , typename... Args, enable_if_t< std::is_pointer< Pointer >::value and std::is_member_function_pointer< F >::value, int > = 0>
constexpr auto kblib::detail::do_invoke (F f, Pointer ptr, Args &&... args) noexcept(noexcept((ptr-> *f)(std::forward< Args >(args)...))) -> decltype(auto)
 
template<typename Member , typename Object , enable_if_t< not std::is_pointer< remove_cvref_t< Object > >::value and std::is_member_object_pointer< Member >::value, int > = 0>
constexpr auto kblib::detail::do_invoke (Member mem, Object &&obj) noexcept -> decltype(auto)
 
template<typename Member , typename Pointer , enable_if_t< std::is_pointer< Pointer >::value and std::is_member_object_pointer< Member >::value, int > = 0>
constexpr auto kblib::detail::do_invoke (Member mem, Pointer ptr) noexcept -> decltype(auto)
 
template<typename F , typename... Args>
constexpr auto kblib::invoke (F &&f, Args &&... args) noexcept(noexcept(detail::do_invoke(std::forward< F >(f), std::forward< Args >(args)...))) -> decltype(auto)
 
template<typename F >
auto kblib::fakestd::not_fn (F &&f) -> detail::not_fn_t< F >
 
template<class ForwardIt >
constexpr auto kblib::fakestd::max_element (ForwardIt first, ForwardIt last) -> ForwardIt
 
template<class ForwardIt , class Compare >
constexpr auto kblib::fakestd::max_element (ForwardIt first, ForwardIt last, Compare comp) -> ForwardIt
 
template<class C >
constexpr auto kblib::fakestd::size (const C &c) -> decltype(c.size())
 
template<class T , std::size_t N>
constexpr auto kblib::fakestd::size (const T(&)[N]) noexcept -> std::size_t
 
template<typename F , typename Arg >
constexpr auto kblib::apply (F &&f, Arg &&arg) noexcept(noexcept(detail::apply_impl< F, Arg >::do_apply(std::forward< F >(f), std::forward< Arg >(arg), std::index_sequence< std::tuple_size< Arg >::value >{}))) -> decltype(auto)
 
template<typename T >
auto kblib::to_unique (gsl::owner< T * > p) -> std::unique_ptr< T >
 
template<typename T , typename D >
auto kblib::to_unique (gsl::owner< T * > p, D &&d) -> std::unique_ptr< T, D >
 
template<typename I >
constexpr auto kblib::to_unsigned (I x) -> std::make_unsigned_t< I >
 Cast integral argument to corresponding unsigned type. More...
 
template<typename I >
constexpr auto kblib::to_signed (I x) -> std::make_signed_t< I >
 Cast integral argument to corresponding signed type. More...
 
template<typename A , typename F >
constexpr auto kblib::signed_cast (F x) -> enable_if_t< std::is_integral< A >::value and std::is_integral< F >::value and std::is_signed< A >::value, std::make_signed_t< F > >
 Cast argument to equivalently-sized type with the same signednessas the template parameter. More...
 
template<typename... Ts>
constexpr auto kblib::detail::ignore (Ts &&...) noexcept -> void
 
template<typename T , std::size_t... Is>
constexpr auto kblib::detail::swap_tuple_impl (T &a, T &b, std::index_sequence< Is... >) noexcept(noexcept(ignore(((void) swap(std::get< Is >(a), std::get< Is >(b)), 0)...))) -> void
 
template<typename T , typename U = T>
constexpr auto kblib::exchange (T &obj, U &&new_value) -> T
 
constexpr auto kblib::detail::msb (std::uintmax_t x) -> std::uintmax_t
 
template<typename Num >
constexpr auto kblib::detail::msb_possible () -> Num
 
template<typename N >
constexpr auto kblib::signed_promote (N x) noexcept -> safe_signed_t< N >
 
template<class InputIt1 , class InputIt2 >
constexpr auto kblib::equal (InputIt1 first1, InputIt1 last1, InputIt2 first2) -> bool
 
template<typename InputIt1 , typename InputIt2 , typename BinaryPredicate , typename kblib::enable_if_t< not std::is_same< InputIt2, BinaryPredicate >::value, int > = 0>
constexpr auto kblib::equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p) -> bool
 
template<class RandomIt1 , class RandomIt2 , typename kblib::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt1 >::iterator_category >::value and std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt2 >::iterator_category >::value, int > = 0>
constexpr auto kblib::equal (RandomIt1 first1, RandomIt1 last1, RandomIt2 first2, RandomIt2 last2) -> bool
 
template<class RandomIt1 , class RandomIt2 , typename BinaryPredicate , typename kblib::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt1 >::iterator_category >::value and std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt2 >::iterator_category >::value, int > = 0>
constexpr auto kblib::equal (RandomIt1 first1, RandomIt1 last1, RandomIt2 first2, RandomIt2 last2, BinaryPredicate p) -> bool
 
template<class InputIt1 , class InputIt2 , typename kblib::enable_if_t< not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt1 >::iterator_category >::value or not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt2 >::iterator_category >::value, int > = 0>
constexpr auto kblib::equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -> bool
 
template<typename InputIt1 , typename InputIt2 , typename BinaryPredicate , typename kblib::enable_if_t< not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt1 >::iterator_category >::value or not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt2 >::iterator_category >::value, int > = 0>
constexpr auto kblib::equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate p) -> bool
 
template<typename C >
constexpr auto kblib::size (const C &c) -> decltype(c.size())
 
template<typename T , std::size_t N>
constexpr auto kblib::size (const T(&)[N]) noexcept -> std::size_t
 
template<class InputIt1 , class InputIt2 >
constexpr auto kblib::lexicographical_compare (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -> bool
 

Variables

template<class Tp , class Up >
constexpr bool kblib::fakestd::is_swappable_with_v = is_swappable_with<Tp, Up>::value
 
template<class Tp >
constexpr bool kblib::fakestd::is_swappable_v = is_swappable<Tp>::value
 
template<class Tp , class Up >
constexpr bool kblib::fakestd::is_nothrow_swappable_with_v = is_nothrow_swappable_with<Tp, Up>::value
 
template<class Tp >
constexpr bool kblib::fakestd::is_nothrow_swappable_v = is_nothrow_swappable<Tp>::value
 
template<class Fn , class... Args>
constexpr bool kblib::fakestd::is_invocable_v = is_invocable<Fn, Args...>::value
 
template<class Ret , class Fn , class... Args>
constexpr bool kblib::fakestd::is_invocable_r_v = is_invocable_r<Ret, Fn, Args...>::value
 
template<class Fn , class... Args>
constexpr bool kblib::fakestd::is_nothrow_invocable_v = is_nothrow_invocable<Fn, Args...>::value
 
template<class Ret , class Fn , class... Args>
constexpr bool kblib::fakestd::is_nothrow_invocable_r_v = is_nothrow_invocable_r<Ret, Fn, Args...>::value
 
struct {
kblib::swap
 
template<typename T >
constexpr std::intmax_t kblib::detail::max_val = std::numeric_limits<T>::max()
 
template<typename T >
constexpr bool kblib::value_detected_v = value_detected<T>::value
 
template<typename T >
constexpr bool kblib::key_detected_v = key_detected<T>::value
 
template<typename T >
constexpr bool kblib::mapped_detected_v = mapped_detected<T>::value
 
template<typename T >
constexpr bool kblib::hash_detected_v = hash_detected<T>::value
 
constexpr struct kblib::in_place_agg_t kblib::in_place_agg
 

Detailed Description

This header provides some features of C++17 <type_traits> and other headers for C++14, as well as some other traits.

Author
killerbee
Date
2019-2021

Definition in file fakestd.h.

Macro Definition Documentation

◆ KBLIB_FAKESTD

#define KBLIB_FAKESTD   (__cplusplus < 201703L)

Definition at line 48 of file fakestd.h.