tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
as_const.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_UTILITY_AS_CONST_HPP
5#define TETL_UTILITY_AS_CONST_HPP
6
7#include <etl/_type_traits/add_const.hpp>
8
9namespace etl {
10
11/// \brief Forms lvalue reference to const type of t.
12template <typename T>
13[[nodiscard]] constexpr auto as_const(T& t) noexcept -> add_const_t<T>&
14{
15 return t; // NOLINT(bugprone-return-const-ref-from-parameter)
16}
17
18template <typename T>
19constexpr auto as_const(T const&&) -> void = delete;
20
21} // namespace etl
22
23#endif // TETL_UTILITY_AS_CONST_HPP
Definition adjacent_find.hpp:9
constexpr auto as_const(T &t) noexcept -> add_const_t< T > &
Forms lvalue reference to const type of t.
Definition as_const.hpp:13
constexpr auto as_const(T const &&) -> void=delete