All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
makeAdaptedSpanDocumentation1TestClass Struct Reference

Public Member Functions

float accumulate (std::vector< std::unique_ptr< float >> const &v)
 
void analyse ()
 

Detailed Description

Definition at line 244 of file span_test.cc.

Member Function Documentation

float makeAdaptedSpanDocumentation1TestClass::accumulate ( std::vector< std::unique_ptr< float >> const &  v)
inline

Definition at line 257 of file span_test.cc.

258  {
259 
260  using src_iterator = std::vector<std::unique_ptr<float>>::const_iterator;
261 
262  float sum = 0.0F;
263  for (float v: util::make_adapted_span(v, boost::make_indirect_iterator<src_iterator>))
264  sum += v;
265 
266  return sum;
267  } // accumulate()
auto make_adapted_span(BIter begin, EIter end, Adaptor &&adaptor)
Definition: span.h:223
void makeAdaptedSpanDocumentation1TestClass::analyse ( )
inline

Definition at line 269 of file span_test.cc.

270  {
271  float const salt = 3.0;
272  constexpr std::size_t N = 10;
273 
274  std::vector<std::unique_ptr<float>> data;
275  for (auto i: util::counter(N))
276  data.push_back(std::make_unique<float>(salt * i));
277 
278  float sum = accumulate(data);
279  float const expectedSum = (N * (N - 1) / 2) * salt;
280 
281  BOOST_TEST(sum == expectedSum);
282 
283  } // analyse()
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
float accumulate(std::vector< std::unique_ptr< float >> const &v)
Definition: span_test.cc:257
process_name largeant stream1 can override from command line with o or output physics producers generator N

The documentation for this struct was generated from the following file: