Embedded Template Library 1.0
etl::select1st< TPair > Struct Template Reference

Functor to select pair::first. More...

#include <utility.h>

Public Types

typedef TPair::first_type type
 type of member pair::first.
 

Public Member Functions

typeoperator() (TPair &p) const
 Function call that return p.first. More...
 
const typeoperator() (const TPair &p) const
 Function call that return p.first. More...
 

Detailed Description

template<typename TPair>
struct etl::select1st< TPair >

Functor to select pair::first.

select1st is a functor object that takes a single argument, a pair, and returns the pair::first element.

Example

using Map = std::map<int, double>;
using Vector = std::vector<int>;
const Map map = {{1, 0.3},
{47, 0.8},
{33, 0.1}};
Vector result{};
// Extract the map keys into a vector
std::transform(map.begin(), map.end(), std::back_inserter(result), etl::select1st<Map::value_type>());
A templated map implementation that uses a fixed size buffer.
Definition: map.h:2667
ETL_NODISCARD ETL_CONSTEXPR14 etl::back_insert_iterator< TContainer > back_inserter(TContainer &container)
Definition: iterator.h:682
Functor to select pair::first.
Definition: utility.h:391
Template Parameters
TPairThe function object's argument type.
See also
select2nd

Member Function Documentation

◆ operator()() [1/2]

template<typename TPair >
const type & etl::select1st< TPair >::operator() ( const TPair &  p) const
inline

Function call that return p.first.

Returns
a reference to member pair::first of the pair p

◆ operator()() [2/2]

template<typename TPair >
type & etl::select1st< TPair >::operator() ( TPair &  p) const
inline

Function call that return p.first.

Returns
a reference to member pair::first of the pair p

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