You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Binds the first N arguments (where N is the number of arguments after the given function to `std::bind_front`) to a given free function, lambda, or member function.
618
+
```c++
619
+
constauto f = [](int a, int b, int c) { return a + b + c; };
620
+
const auto g = std::bind_front(f, 1, 1);
621
+
g(1); // == 3
622
+
```
623
+
624
+
### Uniform container erasure
625
+
Provides `std::erase` and/or `std::erase_if` for a variety of STL containers such as string, list, vector, map, etc.
626
+
627
+
For erasing by value use `std::erase`, or to specify a predicate when to erase elements use `std::erase_if`. Both functions return the number of erased elements.
628
+
629
+
```c++
630
+
std::vector v{0, 1, 0, 2, 0, 3};
631
+
std::erase(v, 0); // v == {1, 2, 3}
632
+
std::erase_if(v, [](int n) { return n == 0; }); // v == {1, 2, 3}
633
+
```
634
+
614
635
## Acknowledgements
615
636
*[cppreference](http://en.cppreference.com/w/cpp) - especially useful for finding examples and documentation of new library features.
616
637
*[C++ Rvalue References Explained](http://web.archive.org/web/20240324121501/http://thbecker.net/articles/rvalue_references/section_01.html) - a great introduction I used to understand rvalue references, perfect forwarding, and move semantics.
C++17 includes the following new language features:
38
40
-[template argument deduction for class templates](#template-argument-deduction-for-class-templates)
@@ -715,6 +717,25 @@ int a[] = {1, 2, 3};
715
717
std::to_array(a); // returns `std::array<int, 3>`
716
718
```
717
719
720
+
### std::bind_front
721
+
Binds the first N arguments (where N is the number of arguments after the given function to `std::bind_front`) to a given free function, lambda, or member function.
722
+
```c++
723
+
constauto f = [](int a, int b, int c) { return a + b + c; };
724
+
const auto g = std::bind_front(f, 1, 1);
725
+
g(1); // == 3
726
+
```
727
+
728
+
### Uniform container erasure
729
+
Provides `std::erase` and/or `std::erase_if` for a variety of STL containers such as string, list, vector, map, etc.
730
+
731
+
For erasing by value use `std::erase`, or to specify a predicate when to erase elements use `std::erase_if`. Both functions return the number of erased elements.
732
+
733
+
```c++
734
+
std::vector v{0, 1, 0, 2, 0, 3};
735
+
std::erase(v, 0); // v == {1, 2, 3}
736
+
std::erase_if(v, [](int n) { return n == 0; }); // v == {1, 2, 3}
737
+
```
738
+
718
739
## C++17 Language Features
719
740
720
741
### Template argument deduction for class templates
0 commit comments