Share via


_1 개체

대체 가능한 인수에 대한 자리 표시자입니다.

구문

namespace placeholders {
    extern unspecified _1, _2, ... _N
} // namespace placeholders (within std)

설명

개체 _1, _2, ... _N 는 각각 Nth 인수를 통해 반환 bind된 개체에 대한 함수 호출에서 첫 번째, 두 번째, ...를 나타내는 자리 표시자입니다. 예를 들어 식이 계산될 때 bind 여섯 번째 인수를 삽입할 위치를 지정하는 데 사용합니다_6.

Microsoft 구현에서 값 _N 은 20입니다.

예제

// std__functional_placeholder.cpp
// compile with: /EHsc
#include <functional>
#include <algorithm>
#include <iostream>

using namespace std::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::bind(product, _1, 2));
    std::cout << std::endl;

    std::for_each(&arg[0], &arg[3], std::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