My Project
Functions
as_const.hpp File Reference
#include "add_const.hpp"

Go to the source code of this file.

Functions

template<typename T >
constexpr add_const_t< T > & bsl::as_const (T &t) noexcept
 Forms lvalue reference to const type of t. More...
 
template<typename T >
constexpr void bsl::as_const (T const &&t) noexcept=delete
 const rvalue reference overload is deleted to disallow rvalue arguments More...
 

Detailed Description

Function Documentation

◆ as_const() [1/2]

template<typename T >
constexpr add_const_t<T>& bsl::as_const ( T &  t)
noexcept

Forms lvalue reference to const type of t.

#include <bsl/as_const.hpp>
#include <bsl/is_same.hpp>
#include <bsl/debug.hpp>
namespace bsl
{
constexpr bool example_as_const_var{};
inline void
example_as_const_overview() noexcept
{
if (is_same<decltype(as_const(example_as_const_var)), bool const &>::value) {
bsl::print() << "success\n";
}
}
}
Template Parameters
Tthe type to form the lvalue reference to const of
Parameters
tthe object of type T to form the const lvalue reference of
Returns
Forms lvalue reference to const type of t

◆ as_const() [2/2]

template<typename T >
constexpr void bsl::as_const ( T const &&  t)
deletenoexcept

const rvalue reference overload is deleted to disallow rvalue arguments

#include <bsl/as_const.hpp>
#include <bsl/is_same.hpp>
#include <bsl/debug.hpp>
namespace bsl
{
constexpr bool example_as_const_var{};
inline void
example_as_const_overview() noexcept
{
if (is_same<decltype(as_const(example_as_const_var)), bool const &>::value) {
bsl::print() << "success\n";
}
}
}
Template Parameters
Tthe type to form the lvalue reference to const of
Parameters
tthe object of type T to form the const lvalue reference of