Search notes:

C++ Standard Library: bind

//
//  g++ -std=c++11 bind.cpp
//
#include <string>
#include <iostream>
#include <functional>


void f(int i, std::string s, char b) {
  std::cout << "i="<<i << ", s="<<s<< ", b=" << b << std::endl;
}

int main() {

    auto bound_1 = std::bind(f, 42                   , "foo"                 , 'a');
    auto bound_2 = std::bind(f, 18                   , std::placeholders::_1 , 'b');
    auto bound_3 = std::bind(f, std::placeholders::_2, std::placeholders::_1 , 'c');

    bound_1();
    bound_2("bar");
    bound_3("baz", 99);

}
Github repository about-cpp-standard-library, path: /functional/bind.cpp
Output:
i=42, s=foo, b=a
i=18, s=bar, b=b
i=99, s=baz, b=c

See also

C++ Standard Library

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758193861, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/CPP-Standard-Library/functional/bind(66): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78