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

◆ contains_only()

template<concepts::option... Opts>
template<concepts::keyword... Keys>
static constexpr auto rbr::settings< Opts >::contains_only ( Keys const &...  ks)
inlinestaticconstexprnoexcept

Checks if rbr::settings contains options based only on selected keywords.

Parameters
ksKeywords to check
Returns
An instance of std::true_type if current setting contains only options based on any of the ks. 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_only( S const& )
{
if constexpr( S::contains_only( "value"_kw, "active"_fl ) )
std::cout << "Correct settings\n";
else
std::cout << "Incorrect settings\n";
}
int main()
{
check_contains_only( rbr::settings("value"_kw = 9) );
check_contains_only( rbr::settings("active"_fl) );
check_contains_only( rbr::settings("malus"_kw = 6.5, "value"_kw = 17) );
check_contains_only( rbr::settings("active"_fl, "value"_kw = 17) );
check_contains_only( rbr::settings("active"_fl, "value"_kw = 17, "other"_kw = false) );
}
Raberu literals namespace.
Definition: keywords.hpp:369
Defines a group of options for processing.
Definition: settings.hpp:50