My Project
Functions
max_of.hpp File Reference

Go to the source code of this file.

Functions

template<typename T >
constexpr T const & bsl::max_of (T const &a, T const &b) noexcept
 Returns a if a is larger than b, otherwise returns b. Note that this function is called max_of to prevent a name collision with numeric_limits<>::max(). More...
 

Detailed Description

Function Documentation

◆ max_of()

template<typename T >
constexpr T const& bsl::max_of ( T const &  a,
T const &  b 
)
noexcept

Returns a if a is larger than b, otherwise returns b. Note that this function is called max_of to prevent a name collision with numeric_limits<>::max().

#include <bsl/max_of.hpp>
#include <bsl/debug.hpp>
namespace bsl
{
inline void
example_max_of_overview() noexcept
{
constexpr bsl::int32 val1{23};
constexpr bsl::int32 val2{42};
if (bsl::max_of(val1, val2) == val2) {
bsl::print() << "success\n";
}
}
}
Template Parameters
TThe type that defines both a and b
Parameters
athe first parameter to compare
bthe second parameter to compare
Returns
Returns a if a is larger than b, otherwise returns b.