raberu v1.1.0
Fancy Named Parameter Library
 
Loading...
Searching...
No Matches

◆ contains()

template<concepts::option... Opts>
template<concepts::keyword Key>
static constexpr auto rbr::settings< Opts >::contains ( Key const &  kw)
inlinestaticconstexprnoexcept

Checks if a given rbr::keyword is stored inside rbr::settings.

Parameters
kwKeyword to check
Returns
An instance of std::true_type if current setting contains an option based on kw. Otherwise, return an instance of std::false_type.

Example:

#include <raberu/raberu.hpp>
#include <iostream>
using namespace rbr::literals;
template<rbr::concepts::settings S>
void check_contains( S const& s)
{
if constexpr( S::contains( "value"_kw ) )
std::cout << "Correct settings: " << s["value"_kw] << '\n';
else
std::cout << "Incorrect settings\n";
}
int main()
{
check_contains( rbr::settings("value"_kw = 9 ) );
check_contains( rbr::settings("malus"_kw = 3.5) );
check_contains( rbr::settings("malus"_kw = 6.5, "value"_kw = 17) );
}
Raberu literals namespace.
Definition: keywords.hpp:369
Defines a group of options for processing.
Definition: settings.hpp:50