This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TfGet< N > Class Template Reference

Function object for retrieving the N'th element of a std::pair or std::tuple. More...

#include <stl.h>

Public Types

template<class PairOrTuple >
using return_type = typename std::tuple_element< N, PairOrTuple >::type
 

Public Member Functions

template<class PairOrTuple >
constexpr return_type< PairOrTuple > & operator() (PairOrTuple &p) const
 
template<class PairOrTuple >
constexpr const return_type< PairOrTuple > & operator() (const PairOrTuple &p) const
 
template<class PairOrTuple >
constexpr return_type< PairOrTuple > && operator() (PairOrTuple &&p) const
 

Detailed Description

template<size_t N>
class TfGet< N >

Function object for retrieving the N'th element of a std::pair or std::tuple.

This is similar to std::get<N>, but wrapped up in a function object suitable for use with STL algorithms.

Example:

const std::vector<std::pair<int, std::string>> pairs = { ... }
std::vector<int> intsOnly(pairs.size());
std::transform(pairs.begin(), pairs.end(), intsOnly.begin(), TfGet<0>());
Function object for retrieving the N'th element of a std::pair or std::tuple.
Definition: stl.h:362

Definition at line 361 of file stl.h.

Member Typedef Documentation

◆ return_type

using return_type = typename std::tuple_element<N, PairOrTuple>::type

Definition at line 365 of file stl.h.

Member Function Documentation

◆ operator()() [1/3]

constexpr const return_type< PairOrTuple > & operator() ( const PairOrTuple &  p) const
inlineconstexpr

Definition at line 374 of file stl.h.

◆ operator()() [2/3]

constexpr return_type< PairOrTuple > && operator() ( PairOrTuple &&  p) const
inlineconstexpr

Definition at line 381 of file stl.h.

◆ operator()() [3/3]

constexpr return_type< PairOrTuple > & operator() ( PairOrTuple &  p) const
inlineconstexpr

Definition at line 368 of file stl.h.


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