This content originally appeared on DEV Community and was authored by 海前 王
#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;
}
#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;
}
#include <iostream>
#include <thread>
int main()
{
unsigned int in = std::thread::hardware_concurrency();
std::cout << in << std::endl;
}
#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;
}
This content originally appeared on DEV Community and was authored by 海前 王