Skip to content

Commit 1d9c6ec

Browse files
author
Colin Robertson
committed
Add some deprecation messages. Address STL issues.
1 parent cec4487 commit 1d9c6ec

17 files changed

+103
-105
lines changed

docs/standard-library/binary-function-struct.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 79b6d53d-644c-4add-b0ba-3a5f40f69c60
77
---
88
# binary_function Struct
99

10-
An empty base struct that defines types that may be inherited by derived classes that provides a binary function object.
10+
An empty base struct that defines types that may be inherited by derived classes that provides a binary function object. Deprecated in C++11, removed in C++17.
1111

1212
## Syntax
1313

docs/standard-library/binary-negate-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 7b86f02c-af7e-4c7f-9df1-08addae4dd65
77
---
88
# binary_negate Class
99

10-
A template class providing a member function that negates the return value of a specified binary function.
10+
A template class providing a member function that negates the return value of a specified binary function. Deprecated in C++17.
1111

1212
## Syntax
1313

docs/standard-library/binder1st-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 6b8ee343-c82f-48f8-867d-06f9d1d324c0
77
---
88
# binder1st Class
99

10-
A template class providing a constructor that converts a binary function object into a unary function object by binding the first argument of the binary function to a specified value.
10+
A template class providing a constructor that converts a binary function object into a unary function object by binding the first argument of the binary function to a specified value. Deprecated in C++11, removed in C++17.
1111

1212
## Syntax
1313

docs/standard-library/binder2nd-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: b2a9c1d1-dfc4-4ca9-a10e-ae84e195a62d
77
---
88
# binder2nd Class
99

10-
A template class providing a constructor that converts a binary function object into a unary function object by binding the second argument of the binary function to a specified value.
10+
A template class providing a constructor that converts a binary function object into a unary function object by binding the second argument of the binary function to a specified value. Deprecated in C++11, removed in C++17.
1111

1212
## Syntax
1313

docs/standard-library/const-mem-fun-ref-t-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 316ddbaa-9f46-4931-8eba-ea4ca66360ef
77
---
88
# const_mem_fun_ref_t Class
99

10-
An adapter class that allows a **const** member function that takes no arguments to be called as a unary function object when initialized with a reference argument.
10+
An adapter class that allows a **const** member function that takes no arguments to be called as a unary function object when initialized with a reference argument. Deprecated in C++11, removed in C++17.
1111

1212
## Syntax
1313

docs/standard-library/const-mem-fun-t-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: f169d381-019b-4a0e-a9a3-54da6d948270
77
---
88
# const_mem_fun_t Class
99

10-
An adapter class that allows a const member function that takes no arguments to be called as a unary function object when initialized with a reference argument.
10+
An adapter class that allows a const member function that takes no arguments to be called as a unary function object when initialized with a reference argument. Deprecated in C++11, removed in C++17.
1111

1212
## Syntax
1313

docs/standard-library/const-mem-fun1-ref-t-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 8220d373-fa1c-44be-a21d-96d49b3ea6bb
77
---
88
# const_mem_fun1_ref_t Class
99

10-
An adapter class that allows a **const** member function that takes a single argument to be called as a binary function object when initialized with a reference argument.
10+
An adapter class that allows a **const** member function that takes a single argument to be called as a binary function object when initialized with a reference argument. Deprecated in C++11, removed in C++17.
1111

1212
## Syntax
1313

docs/standard-library/const-mem-fun1-t-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 250fac30-9663-4133-9051-6303f76ea259
77
---
88
# const_mem_fun1_t Class
99

10-
An adapter class that allows a **const** member function that takes a single argument to be called as a binary function object when initialized with a pointer argument.
10+
An adapter class that allows a **const** member function that takes a single argument to be called as a binary function object when initialized with a pointer argument. Deprecated in C++11, removed in C++17.
1111

1212
## Syntax
1313

docs/standard-library/functional-functions.md

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ ms.assetid: c34d0b45-50a7-447a-9368-2210d06339a4
99

1010
||||
1111
|-|-|-|
12-
|[bind](#bind)|[bind1st](#bind1st)|[bind2nd](#bind2nd)|
13-
|[bit_and](#bit_and)|[bit_not](#bit_not)|[bit_or](#bit_or)|
14-
|[bit_xor](#bit_xor)|[cref](#cref)|[mem_fn](#mem_fn)|
15-
|[mem_fun](#mem_fun)|[mem_fun_ref](#mem_fun_ref)|[not1](#not1)|
16-
|[not2](#not2)|[not_fn](#not_fn)|[ptr_fun](#ptr_fun)|
17-
|[ref](#ref)|[swap](#swap)|
12+
| [bind](#bind) | [bit_and](#bit_and) | [bit_not](#bit_not) |
13+
| [bit_or](#bit_or) | [bit_xor](#bit_xor) | [cref](#cref) |
14+
| [mem_fn](#mem_fn) | [not_fn](#not_fn) | [ref](#ref) |
15+
| [swap](#swap) | | |
16+
17+
The following functions are deprecated in C++11 and removed in C++17:
18+
19+
||||
20+
|-|-|-|
21+
|[bind1st](#bind1st)|[bind2nd](#bind2nd)|[mem_fun](#mem_fun)|
22+
|[mem_fun_ref](#mem_fun_ref)|[ptr_fun](#ptr_fun)||
23+
24+
The following functions are deprecated in C++17:
25+
26+
|||
27+
|-|-|
28+
|[not1](#not1)|[not2](#not2)|
1829

1930
## <a name="bind"></a> bind
2031

@@ -119,7 +130,7 @@ int main()
119130

120131
## <a name="bind1st"></a> bind1st
121132

122-
A helper template function that creates an adaptor to convert a binary function object into a unary function object by binding the first argument of the binary function to a specified value.
133+
A helper template function that creates an adaptor to convert a binary function object into a unary function object by binding the first argument of the binary function to a specified value. Deprecated in C++11, removed in C++17.
123134

124135
```cpp
125136
template <class Operation, class Type>
@@ -213,7 +224,7 @@ The number of elements in v1 less than 10 is: 2.
213224

214225
## <a name="bind2nd"></a> bind2nd
215226

216-
A helper template function that creates an adaptor to convert a binary function object into a unary function object by binding the second argument of the binary function to a specified value.
227+
A helper template function that creates an adaptor to convert a binary function object into a unary function object by binding the second argument of the binary function to a specified value. Deprecated in C++11, removed in C++17.
217228

218229
```cpp
219230
template <class Operation, class Type>
@@ -348,7 +359,7 @@ The `bit_and` functor is restricted to integral types for the basic data types,
348359
349360
## <a name="bit_not"></a> bit_not
350361
351-
A predefined function object that performs the bitwise complement (NOT) operation (unary `operator~`) on its argument.
362+
A predefined function object that performs the bitwise complement (NOT) operation (unary `operator~`) on its argument. Added in C++14.
352363
353364
```cpp
354365
template <class Type = void>
@@ -585,7 +596,7 @@ int main()
585596

586597
## <a name="mem_fun"></a> mem_fun
587598

588-
Helper template functions used to construct function object adaptors for member functions when initialized with pointer arguments.
599+
Helper template functions used to construct function object adaptors for member functions when initialized with pointer arguments. Deprecated in C++11, removed in C++17.
589600

590601
```cpp
591602
template <class Result, class Type>
@@ -672,7 +683,7 @@ int main( )
672683

673684
## <a name="mem_fun_ref"></a> mem_fun_ref
674685

675-
Helper template functions used to construct function object adaptors for member functions when initialized by using reference arguments.
686+
Helper template functions used to construct function object adaptors for member functions when initialized by using reference arguments. Deprecated in C++11, removed in C++17.
676687

677688
```cpp
678689
template <class Result, class Type>
@@ -925,11 +936,11 @@ Resorted vector v1 = ( 26500 19169 18467 6334 6262 6262 41 )
925936

926937
## <a name="not_fn"></a> not_fn
927938

928-
Intended as a generic replacement for negation function wrappers `std::not1` and `std::not2`, this function template creates a forwarding call wrapper that returns the logical negation of the result of its contained callable object. It preserves the const qualification and value category behavior of the wrapped function object. This template function is new in C++17, and replaces the deprecated `std::not1`, `std::not2`, `std::unary_negate` and `std::binary_negate`.
939+
The `not_fn` function template takes a callable object and returns a callable object. When the returned callable object is later invoked with some arguments, it passes them to the original callable object, and logically negates the result. It preserves the const qualification and value category behavior of the wrapped callable object. `not_fn` is new in C++17, and replaces the deprecated `std::not1`, `std::not2`, `std::unary_negate` and `std::binary_negate`.
929940

930941
```cpp
931942
template <class Callable>
932-
unspecified not_fn(Callable&& func);
943+
/* unspecified */ not_fn(Callable&& func);
933944
```
934945

935946
### Parameters
@@ -952,16 +963,16 @@ public:
952963
call_wrapper(call_wrapper const&) = default;
953964

954965
template<class... Args>
955-
auto operator()(Args&&...) & -> decltype(!declval<result_of_t<FD&(Args...)>>());
966+
auto operator()(Args&&...) & -> decltype(!declval<invoke_result_t<FD&(Args...)>>());
956967

957968
template<class... Args>
958-
auto operator()(Args&&...) const& -> decltype(!declval<result_of_t<FD const&(Args...)>>());
969+
auto operator()(Args&&...) const& -> decltype(!declval<invoke_result_t<FD const&(Args...)>>());
959970

960971
template<class... Args>
961-
auto operator()(Args&&...) && -> decltype(!declval<result_of_t<FD(Args...)>>());
972+
auto operator()(Args&&...) && -> decltype(!declval<invoke_result_t<FD(Args...)>>());
962973

963974
template<class... Args>
964-
auto operator()(Args&&...) const&& -> decltype(!declval<result_of_t<FD const(Args...)>>());
975+
auto operator()(Args&&...) const&& -> decltype(!declval<invoke_result_t<FD const(Args...)>>());
965976

966977
private:
967978
FD fd;
@@ -973,10 +984,10 @@ The explicit constructor on the callable object *func* requires type `std::decay
973984
The wrapper exposes call operators distinguished by lvalue or rvalue reference category and const qualification as shown here,
974985
975986
```cpp
976-
template<class... Args> auto operator()(Args&&... args) & -> decltype(!declval<result_of_t<FD&(Args...)>>());
977-
template<class... Args> auto operator()(Args&&... args) const& -> decltype(!declval<result_of_t<FD const&(Args...)>>());
978-
template<class... Args> auto operator()(Args&&... args) && -> decltype(!declval<result_of_t<FD(Args...)>>());
979-
template<class... Args> auto operator()(Args&&... args) const&& -> decltype(!declval<result_of_t<FD const(Args...)>>());
987+
template<class... Args> auto operator()(Args&&... args) & -> decltype(!declval<invoke_result_t<FD&(Args...)>>());
988+
template<class... Args> auto operator()(Args&&... args) const& -> decltype(!declval<invoke_result_t<FD const&(Args...)>>());
989+
template<class... Args> auto operator()(Args&&... args) && -> decltype(!declval<invoke_result_t<FD(Args...)>>());
990+
template<class... Args> auto operator()(Args&&... args) const&& -> decltype(!declval<invoke_result_t<FD const(Args...)>>());
980991
```
981992

982993
The first two are equivalent to `return !INVOKE(fd, std::forward<Args>(args)...)`, and the second two are equivalent to `return !INVOKE(std::move(fd), std::forward<Args>(args)...)`.
@@ -989,54 +1000,43 @@ The first two are equivalent to `return !INVOKE(fd, std::forward<Args>(args)...)
9891000
#include <vector>
9901001
#include <algorithm>
9911002
#include <functional>
992-
#include <cstdlib>
9931003
#include <iostream>
9941004

9951005
int main()
9961006
{
997-
using namespace std;
998-
vector <int> v1;
1007+
std::vector<int> v1 = { 99, 6264, 41, 18467, 6334, 26500, 19169 };
1008+
auto divisible_by_3 = [](int i){ return i % 3 == 0; };
9991009

1000-
int i;
1001-
v1.push_back( 6262 );
1002-
v1.push_back( 6262 );
1003-
for ( i = 0 ; i < 5 ; i++ )
1010+
std::cout << "Vector v1 = ( " ;
1011+
for (const auto& item : v1)
10041012
{
1005-
v1.push_back(rand());
1013+
std::cout << item << " ";
10061014
}
1007-
1008-
cout << "Original vector v1 = ( " ;
1009-
for (const auto& item : v1)
1010-
cout << item << " ";
1011-
cout << ")" << endl;
1012-
1013-
// To sort in ascending order,
1014-
// use default binary predicate less<>()
1015-
sort(v1.begin(), v1.end());
1016-
cout << "Sorted vector v1 = ( " ;
1017-
for (const auto& item : v1)
1018-
cout << item << " ";
1019-
cout << ")" << endl;
1020-
1021-
// To sort in descending order,
1022-
// use the helper function not_fn
1023-
sort(v1.begin(), v1.end(), not_fn(less<>()));
1024-
cout << "Resorted vector v1 = ( " ;
1025-
for (const auto& item : v1)
1026-
cout << item << " ";
1027-
cout << ")" << endl;
1015+
std::cout << ")" << std::endl;
1016+
1017+
// Count the number of vector elements divisible by 3.
1018+
int divisible =
1019+
std::count_if(v1.begin(), v1.end(), divisible_by_3);
1020+
std::cout << "Elements divisible by three: "
1021+
<< divisible << std::endl;
1022+
1023+
// Count the number of vector elements not divisible by 3.
1024+
int not_divisible =
1025+
std::count_if(v1.begin(), v1.end(), std::not_fn(divisible_by_3));
1026+
std::cout << "Elements not divisible by three: "
1027+
<< not_divisible << std::endl;
10281028
}
10291029
```
10301030

10311031
```Output
1032-
Original vector v1 = ( 6262 6262 41 18467 6334 26500 19169 )
1033-
Sorted vector v1 = ( 41 6262 6262 6334 18467 19169 26500 )
1034-
Resorted vector v1 = ( 26500 19169 18467 6334 6262 6262 41 )
1032+
Vector v1 = ( 99 6264 41 18467 6334 26500 19169 )
1033+
Elements divisible by three: 2
1034+
Elements not divisible by three: 5
10351035
```
10361036

10371037
## <a name="ptr_fun"></a> ptr_fun
10381038

1039-
Helper template functions used to convert unary and binary function pointers, respectively, into unary and binary adaptable functions.
1039+
Helper template functions used to convert unary and binary function pointers, respectively, into unary and binary adaptable functions. Deprecated in C++11, removed in C++17.
10401040

10411041
```cpp
10421042
template <class Arg, class Result>

0 commit comments

Comments
 (0)