Skip to content

Latest commit

 

History

History
115 lines (94 loc) · 2.29 KB

File metadata and controls

115 lines (94 loc) · 2.29 KB
title _1 Object | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-standard-libraries
ms.tgt_pltfrm
ms.topic article
f1_keywords
_1
std::_1
functional/std::_1
dev_langs
C++
helpviewer_keywords
_1 object
ms.assetid 30c3c480-ff31-4708-94be-7d0d65f243c9
caps.latest.revision 24
author corob-msft
ms.author corob
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

_1 Object

Placeholders for replaceable arguments.

Syntax

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

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. 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 20.

Example

// 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  

Requirements

Header: <functional>

Namespace: std

See Also

bind
is_placeholder Class