Files
rippled/include/xrpl/beast/utility/maybe_const.h

21 lines
483 B
C++

#pragma once
#include <type_traits>
namespace beast {
/** Makes T const or non const depending on a bool. */
template <bool IsConst, class T>
struct MaybeConst
{
explicit MaybeConst() = default;
using type = std::
conditional_t<IsConst, typename std::remove_const<T>::type const, std::remove_const_t<T>>;
};
/** Alias for omitting `typename`. */
template <bool IsConst, class T>
using maybe_const_t = typename MaybeConst<IsConst, T>::type;
} // namespace beast