DEV Community

海前 王
海前 王

Posted on

c++ 1 1 placeholder

#include <iostream>     // std::cout, std::boolalpha
#include <functional>   // std::bind, std::plus, std::placeholders, std::is_bind_expression

int main() {
    using namespace std::placeholders;  // introduces _1
    auto increase_int = std::bind(std::plus<int>(), _2, 1);

    std::cout << std::boolalpha;
    std::cout << std::is_bind_expression<decltype(increase_int)>::value << '\n';

    return 0;
}
Enter fullscreen mode Exit fullscreen mode
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int numbers[] = { 10,20,30,40,50,10 };
    int cx;
    cx = count_if(numbers, numbers + 6, bind(less<int>(), std::placeholders::_1, 100));
    cout << "There are " << cx << " elements that are less than 40.\n";

    cx = count_if(numbers, numbers + 6, bind(less<int>(),100, std::placeholders::_2));
    cout << "There are " << cx << " elements that are not less than 40.\n";

    system("pause");
    return 0;
}
Enter fullscreen mode Exit fullscreen mode
#include <iostream>
#include <thread>
int main()
{
    unsigned int in = std::thread::hardware_concurrency();
    std::cout << in << std::endl;
}
Enter fullscreen mode Exit fullscreen mode

#include <iostream>
#include<list>
using namespace std;
int main()
{
    std::cout << "Hello World!\n";
    list<int >  li{ 1,2,3,4 };
    list<int>::iterator it1;
    //list<int>::iterator it2;
    it1 = li.begin();
//it2 = it1;
    while (true) {
        list<int>::iterator it2=it1;

        it2++;
        cout <<"\n" ;
        if (it2 == li.end())
        {
           // cout << *it2;
            cout << "hello";
            break;
        }
        if(it1!=li.end())
        {
            it1++;
            cout << "\n";
        }
        if(it1==li.end())
        {
            it1--;
        }
    }
  //  cout << *it2;
}
Enter fullscreen mode Exit fullscreen mode

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay