Files
rippled/include/xrpl/beast/utility/maybe_const.h
2025-10-23 11:04:30 -04:00

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