Skip to content

Commit

Permalink
Provide some c++17 type_traits convenience for c++11
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandres committed Mar 14, 2024
1 parent 05216c7 commit fb7deaf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion zypp-core/base/Easy.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define ZYPP_BASE_EASY_H

#include <cstdio>
#include <type_traits>
#include <zypp/base/TypeTraits.h>

/** Convenient for-loops using iterator.
* \code
Expand Down
39 changes: 39 additions & 0 deletions zypp/base/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,43 @@

#include <type_traits>

///////////////////////////////////////////////////////////////////
// Helper types from https://en.cppreference.com/
namespace std
{
#if __cplusplus < 202002L

#endif // __cplusplus < 202002L


#if __cplusplus < 201703L
template< class Base, class Derived >
inline constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;

template< class T >
inline constexpr bool is_integral_v = is_integral<T>::value;

template< class T >
inline constexpr bool is_pointer_v = is_pointer<T>::value;
#endif // __cplusplus < 201703L


#if __cplusplus < 201402L
template< bool B, class T, class F >
using conditional_t = typename conditional<B,T,F>::type;

template< bool B, class T = void >
using enable_if_t = typename enable_if<B,T>::type;

template< class T >
using remove_reference_t = typename remove_reference<T>::type;

template< class T >
using result_of_t = typename result_of<T>::type;

template< class T >
using underlying_type_t = typename underlying_type<T>::type;
#endif // __cplusplus < 201402L
} // namespace std
///////////////////////////////////////////////////////////////////
#endif // ZYPP_TYPETRAITS_H

0 comments on commit fb7deaf

Please sign in to comment.