mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
26 lines
613 B
C++
26 lines
613 B
C++
#ifndef BEAST_UTILITY_MAYBE_CONST_H_INCLUDED
|
|
#define BEAST_UTILITY_MAYBE_CONST_H_INCLUDED
|
|
|
|
#include <type_traits>
|
|
|
|
namespace beast {
|
|
|
|
/** Makes T const or non const depending on a bool. */
|
|
template <bool IsConst, class T>
|
|
struct maybe_const
|
|
{
|
|
explicit maybe_const() = default;
|
|
using type = typename std::conditional<
|
|
IsConst,
|
|
typename std::remove_const<T>::type const,
|
|
typename std::remove_const<T>::type>::type;
|
|
};
|
|
|
|
/** Alias for omitting `typename`. */
|
|
template <bool IsConst, class T>
|
|
using maybe_const_t = typename maybe_const<IsConst, T>::type;
|
|
|
|
} // namespace beast
|
|
|
|
#endif
|