#include <iostream>
#include <vector>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/range/adaptor/transformed.hpp>
int main() {
const std::string input_string = "Hello world! String with spaces.";
std::vector<std::string> words;
boost::split(words, input_string, boost::algorithm::is_any_of(" "), boost::algorithm::token_compress_on);
std::cout << "{"
<< boost::algorithm::join(words | boost::adaptors::transformed([](auto &s){return "\"" + s + "\"";}), ", ")
<< "}"
<< std::endl;
return 0;
}
То есть, например, тут не определено какая вызовется первой, но это и не важно.
x = func_1() + func_2();
#include <iostream>
int x = 2;
int func_1() {
x *= 10;
return x;
}
int func_2() {
x += 10;
return x;
}
int main() {
std::cout << func_1() + func_2() << std::endl;
return 0;
}
copy
?std::copy(std::istreambuf_iterator<BYTE>(InputFileData), std::std::istreambuf_iterator<BYTE>(), std::back_inserter(DataBuf));
TData DataBuf(std::istreambuf_iterator<BYTE>(InputFileData), std::std::istreambuf_iterator<BYTE>());
Или я чего-то не понимаю?
#include <iostream>
#include <cmath>
using namespace std;
int main() {
const double eps = 0.0001;
double x0 = 1;
double b = 0;
do {
const double xn = -log(x0 / 3);
b = abs(xn - x0);
x0 = xn;
} while (b > eps);
cout << "x = " << x0 << endl;
return 0;
}
xn = x0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using IntV = vector<int>;
int main(int argc, char const *argv[]) {
IntV v = {0, 9, 4, 6, 7, 8, 5, 6};
size_t count = 0;
for_each(begin(v), end(v), [](IntV::value_type x){cout << x << " ";});
cout << endl;
sort(begin(v), end(v), [&count /*closure*/](IntV::value_type &a, IntV::value_type &b){
++count;
return a < b;
});
cout << count << endl;
for_each(begin(v), end(v), [](IntV::value_type x){cout << x << " ";});
cout << endl;
return 0;
}
set<int> A_union_B;
set<int> diff_union;
set_union(begin(A), end(A),
begin(B), end(B),
inserter(A_union_B, begin(A_union_B)));
set_difference(begin(universum), end(universum),
begin(A_union_B), end(A_union_B),
inserter(diff_union, begin(diff_union)));