Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Placeholders for replaceable arguments.
namespace placeholders {
extern unspecified _1, _2, ... _M
} // namespace placeholders (within std::tr1)
Remarks
The objects _1, _2, ... _M are placeholders designating the first, second, ..., Mth argument, respectively in a function call to an object returned by bind Function. You use _N to specify where the Nth argument should be inserted when the bind expression is evaluated.
In this implementation the value of M is 10.
Example
// 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);
}
1^2 == 1 2^2 == 4 3^2 == 9 1*2 == 2 2*2 == 4 3*2 == 6 1^2 == 1 2^2 == 4 3^2 == 9
Requirements
Header: <functional>
Namespace: std