Condividi tramite


_1 Object

Segnaposto per gli argomenti sostituibili.

namespace placeholders {
  extern unspecified _1, _2, ... _M
  } // namespace placeholders (within std::tr1)

Note

Gli oggetti _1, _2, ... _M sono segnaposto che definiscono il primo, il secondo,…, emmesimo argomento, rispettivamente in una chiamata di funzione a un oggetto restituito da bind Function.Utilizzare _N per specificare dove l'ennesimo argomento deve essere inserito all'espressione di associazione viene valutata.

In questa implementazione il valore M è 10.

Esempio

 

// std_tr1__functional__placeholder.cpp 
// compile with: /EHsc 
#include <functional> 
#include <algorithm> 
#include <iostream> 
 
using namespace std::tr1::placeholders; 
 
void square(double x) 
    { 
    std::cout << x << "^2 == " << x * x << std::endl; 
    } 
 
void product(double x, double y) 
    { 
    std::cout << x << "*" << y << " == " << x * y << std::endl; 
    } 
 
int main() 
    { 
    double arg[] = {1, 2, 3}; 
 
    std::for_each(&arg[0], &arg[3], square); 
    std::cout << std::endl; 
 
    std::for_each(&arg[0], &arg[3], std::tr1::bind(product, _1, 2)); 
    std::cout << std::endl; 
 
    std::for_each(&arg[0], &arg[3], std::tr1::bind(square, _1)); 
 
    return (0); 
    } 
 
  

Requisiti

intestazione: <functional>

Spazio dei nomi: deviazione standard

Vedere anche

Riferimenti

bind Function

is_placeholder Class