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

◆ fetch()

template<concepts::keyword K, concepts::option... Os>
constexpr decltype(auto) rbr::fetch ( K const &  k,
Os const &...  os 
)
constexpr

Retrieved a value via a keyword.

Retrieve the value bound to a given keyword k inside a variadic list of rbr::options. If such a keyword is not present, either an instance of rbr::unknown_key is returned or a default value or function call will be returned.

Parameters
kKeywords to check
osOptions to inspect
Returns
If any, the value bound to k.

Helper Types

namespace rbr::result
{
template<auto Keyword, typename... Sources> struct fetch
template<auto Keyword, typename... Sources>
using fetch_t = typename fetch<Keyword,Sources...>::type;
}
constexpr decltype(auto) fetch(K const &k, Os const &... os)
Retrieved a value via a keyword.
Definition: fetch.hpp:41
Raberu helper traits namespace.
Definition: drop.hpp:64

Return the type of a call to rbr::fetch.

Example:

#include <raberu/raberu.hpp>
#include <iostream>
int main()
{
using namespace rbr::literals;
int i = 77;
auto values = rbr::settings("size"_kw = 75ULL, "transparent"_fl);
std::cout << rbr::fetch ( "transparent"_fl, values) << "\n";
std::cout << rbr::fetch ( "size"_kw, "size"_kw = 75ULL, "transparent"_fl) << "\n";
std::cout << rbr::fetch ( "value"_kw | 13.37, "size"_kw = 75ULL, "transparent"_fl) << "\n";
std::cout << rbr::fetch ( "modal"_fl | rbr::call([&]() { return i++; })
, "size"_kw = 75ULL, "transparent"_fl
) << "\n\n";
std::cout << "i = " << i << "\n";
}
constexpr auto values(rbr::settings< Opts... > const &s)
Retrieved the list of all value stored in a settings.
Definition: keys_values.hpp:91
Raberu literals namespace.
Definition: keywords.hpp:369
Callable object wrapper for functional default value.
Definition: keywords.hpp:31
Defines a group of options for processing.
Definition: settings.hpp:50