Faker C++
Loading...
Searching...
No Matches
faker::helper Namespace Reference

Classes

struct  WeightedElement
 Get a random element by weight from a vector. More...
 

Concepts

concept  input_range_with_faster_size_compute_than_linear_rng
 

Functions

template<input_range_with_faster_size_compute_than_linear_rng Range>
decltype(auto) randomElement (Range &&range)
 
template<std::ranges::input_range Range>
auto randomElement (Range &&range)
 
template<input_range_with_faster_size_compute_than_linear_rng Range1, input_range_with_faster_size_compute_than_linear_rng Range2>
decltype(auto) randomElement (Range1 &&range1, Range2 &&range2)
 Get a random element from one of two ranges, without concatenating them.
 
template<class T >
weightedRandomElement (const std::vector< WeightedElement< T > > &data)
 

Function Documentation

◆ randomElement() [1/3]

template<input_range_with_faster_size_compute_than_linear_rng Range>
decltype(auto) faker::helper::randomElement ( Range && range)

◆ randomElement() [2/3]

template<std::ranges::input_range Range>
auto faker::helper::randomElement ( Range && range)

◆ randomElement() [3/3]

template<input_range_with_faster_size_compute_than_linear_rng Range1, input_range_with_faster_size_compute_than_linear_rng Range2>
decltype(auto) faker::helper::randomElement ( Range1 && range1,
Range2 && range2 )

Get a random element from one of two ranges, without concatenating them.

Template Parameters
Range1the type of the first range.
Range2the type of the second range.
Parameters
range1the first range.
range2the second range.
Exceptions
std::invalid_argumentif both ranges are empty.
Returns
a random element from range1 or range2.
faker::helper::randomElement(malesLastNames, femalesLastNames) // "Smith"
decltype(auto) randomElement(Range &&range)
Definition helper.h:17

◆ weightedRandomElement()

template<class T >
T faker::helper::weightedRandomElement ( const std::vector< WeightedElement< T > > & data)