Skip to content

Commit 0db63b2

Browse files
authored
Merge pull request #752 from MicrosoftDocs/master
4/23 AM Publish
2 parents ef859dd + 9c72b08 commit 0db63b2

File tree

634 files changed

+148599
-140241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

634 files changed

+148599
-140241
lines changed

docs/standard-library/1-object.md

Lines changed: 79 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -18,79 +18,83 @@ manager: "ghogen"
1818
ms.workload: ["cplusplus"]
1919
---
2020
# _1 Object
21-
Placeholders for replaceable arguments.
22-
23-
## Syntax
24-
25-
```
26-
namespace placeholders {
21+
22+
Placeholders for replaceable arguments.
23+
24+
## Syntax
25+
26+
```cpp
27+
namespace placeholders {
2728
extern unspecified _1,
28-
_2, ... _M
29-
} // namespace placeholders (within std)
30-
```
31-
32-
## Remarks
33-
The objects `_1, _2, ... _M` are placeholders designating the first, second, ..., Mth argument, respectively in a function call to an object returned by [bind](../standard-library/functional-functions.md#bind). You use `_N` to specify where the Nth argument should be inserted when the bind expression is evaluated.
34-
35-
In this implementation the value of `M` is 20.
36-
37-
## Example
38-
39-
```cpp
40-
// std__functional_placeholder.cpp
41-
// compile with: /EHsc
42-
#include <functional>
43-
#include <algorithm>
44-
#include <iostream>
45-
46-
using namespace std::placeholders;
47-
48-
void square(double x)
49-
{
50-
std::cout << x << "^2 == " << x * x << std::endl;
51-
}
52-
53-
void product(double x, double y)
54-
{
55-
std::cout << x << "*" << y << " == " << x * y << std::endl;
56-
}
57-
58-
int main()
59-
{
60-
double arg[] = {1, 2, 3};
61-
62-
std::for_each(&arg[0], &arg[3], square);
63-
std::cout << std::endl;
64-
65-
std::for_each(&arg[0], &arg[3], std::bind(product, _1, 2));
66-
std::cout << std::endl;
67-
68-
std::for_each(&arg[0], &arg[3], std::bind(square, _1));
69-
70-
return (0);
71-
}
72-
73-
```
74-
75-
```Output
76-
1^2 == 1
77-
2^2 == 4
78-
3^2 == 9
79-
80-
1*2 == 2
81-
2*2 == 4
82-
3*2 == 6
83-
84-
1^2 == 1
85-
2^2 == 4
86-
3^2 == 9
87-
```
88-
89-
## Requirements
90-
**Header:** \<functional>
91-
92-
**Namespace:** std
93-
94-
## See Also
95-
[bind](../standard-library/functional-functions.md#bind)
96-
[is_placeholder Class](../standard-library/is-placeholder-class.md)
29+
_2, ... _M
30+
} // namespace placeholders (within std)
31+
```
32+
33+
## Remarks
34+
35+
The objects `_1, _2, ... _M` are placeholders designating the first, second, ..., Mth argument, respectively in a function call to an object returned by [bind](../standard-library/functional-functions.md#bind). You use `_N` to specify where the Nth argument should be inserted when the bind expression is evaluated.
36+
37+
In this implementation the value of `M` is 20.
38+
39+
## Example
40+
41+
```cpp
42+
// std__functional_placeholder.cpp
43+
// compile with: /EHsc
44+
#include <functional>
45+
#include <algorithm>
46+
#include <iostream>
47+
48+
using namespace std::placeholders;
49+
50+
void square(double x)
51+
{
52+
std::cout << x << "^2 == " << x * x << std::endl;
53+
}
54+
55+
void product(double x, double y)
56+
{
57+
std::cout << x << "*" << y << " == " << x * y << std::endl;
58+
}
59+
60+
int main()
61+
{
62+
double arg[] = {1, 2, 3};
63+
64+
std::for_each(&arg[0], &arg[3], square);
65+
std::cout << std::endl;
66+
67+
std::for_each(&arg[0], &arg[3], std::bind(product, _1, 2));
68+
std::cout << std::endl;
69+
70+
std::for_each(&arg[0], &arg[3], std::bind(square, _1));
71+
72+
return (0);
73+
}
74+
75+
```
76+
77+
```Output
78+
1^2 == 1
79+
2^2 == 4
80+
3^2 == 9
81+
82+
1*2 == 2
83+
2*2 == 4
84+
3*2 == 6
85+
86+
1^2 == 1
87+
2^2 == 4
88+
3^2 == 9
89+
```
90+
91+
## Requirements
92+
93+
**Header:** \<functional>
94+
95+
**Namespace:** std
96+
97+
## See also
98+
99+
[bind](../standard-library/functional-functions.md#bind)<br/>
100+
[is_placeholder Class](../standard-library/is-placeholder-class.md)<br/>

docs/standard-library/add-const-class.md

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,56 @@ manager: "ghogen"
1818
ms.workload: ["cplusplus"]
1919
---
2020
# add_const Class
21-
Makes const type from type.
22-
23-
## Syntax
24-
25-
```
26-
template <class Ty>
21+
22+
Makes const type from type.
23+
24+
## Syntax
25+
26+
```cpp
27+
template <class Ty>
2728
struct add_const;
28-
```
29-
30-
#### Parameters
31-
`Ty`
32-
The type to modify.
33-
34-
## Remarks
35-
An instance of the type modifier holds a modified-type that is `Ty` if `Ty` is a reference, a function, or a const-qualified type, otherwise `const Ty`.
36-
37-
## Example
38-
39-
```cpp
40-
// std__type_traits__add_const.cpp
41-
// compile with: /EHsc
42-
#include <type_traits>
43-
#include <iostream>
44-
45-
int main()
46-
{
47-
std::add_const<int>::type *p = (const int *)0;
48-
49-
p = p; // to quiet "unused" warning
50-
std::cout << "add_const<int> == "
51-
<< typeid(*p).name() << std::endl;
52-
53-
return (0);
54-
}
55-
```
56-
57-
```Output
58-
add_const<int> == int
59-
```
60-
61-
## Requirements
62-
**Header:** \<type_traits>
63-
64-
**Namespace:** std
65-
66-
## See Also
67-
[<type_traits>](../standard-library/type-traits.md)
68-
[remove_const Class](../standard-library/remove-const-class.md)
29+
```
30+
31+
### Parameters
32+
33+
`Ty`
34+
The type to modify.
35+
36+
## Remarks
37+
38+
An instance of the type modifier holds a modified-type that is `Ty` if `Ty` is a reference, a function, or a const-qualified type, otherwise `const Ty`.
39+
40+
## Example
41+
42+
```cpp
43+
// std__type_traits__add_const.cpp
44+
// compile with: /EHsc
45+
#include <type_traits>
46+
#include <iostream>
47+
48+
int main()
49+
{
50+
std::add_const<int>::type *p = (const int *)0;
51+
52+
p = p; // to quiet "unused" warning
53+
std::cout << "add_const<int> == "
54+
<< typeid(*p).name() << std::endl;
55+
56+
return (0);
57+
}
58+
```
59+
60+
```Output
61+
add_const<int> == int
62+
```
63+
64+
## Requirements
65+
66+
**Header:** \<type_traits>
67+
68+
**Namespace:** std
69+
70+
## See also
71+
72+
[<type_traits>](../standard-library/type-traits.md)<br/>
73+
[remove_const Class](../standard-library/remove-const-class.md)<br/>

docs/standard-library/add-cv-class.md

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,54 +18,57 @@ manager: "ghogen"
1818
ms.workload: ["cplusplus"]
1919
---
2020
# add_cv Class
21-
Makes const volatile type from type.
22-
23-
## Syntax
24-
25-
```
26-
template <class T>
27-
struct add_cv;
28-
21+
22+
Makes const volatile type from type.
23+
24+
## Syntax
25+
26+
```cpp
27+
template <class T>
28+
struct add_cv;
29+
2930
template <class T>
30-
using add_cv_t = typename add_cv<T>::type;
31-
```
32-
33-
#### Parameters
34-
*T*
35-
The type to modify.
36-
37-
## Remarks
38-
An instance of the modified type `add_cv<T>` has a `type` member typedef equivalent to *T* modified by both [add_volatile](../standard-library/add-volatile-class.md) and [add_const](../standard-library/add-const-class.md), unless *T* already has the cv-qualifiers, is a reference, or is a function.
39-
31+
using add_cv_t = typename add_cv<T>::type;
32+
```
33+
34+
### Parameters
35+
36+
*T*
37+
The type to modify.
38+
39+
## Remarks
40+
41+
An instance of the modified type `add_cv<T>` has a `type` member typedef equivalent to *T* modified by both [add_volatile](../standard-library/add-volatile-class.md) and [add_const](../standard-library/add-const-class.md), unless *T* already has the cv-qualifiers, is a reference, or is a function.
42+
4043
The `add_cv_t<T>` helper type is a shortcut to access the `add_cv<T>` member typedef `type`.
41-
42-
## Example
43-
44-
```cpp
44+
45+
## Example
46+
47+
```cpp
4548
// add_cv.cpp
4649
// compile by using: cl /EHsc /W4 add_cv.cpp
47-
#include <type_traits>
48-
#include <iostream>
50+
#include <type_traits>
51+
#include <iostream>
4952

5053
struct S {
51-
void f() {
52-
std::cout << "invoked non-cv-qualified S.f()" << std::endl;
54+
void f() {
55+
std::cout << "invoked non-cv-qualified S.f()" << std::endl;
5356
}
54-
void f() const {
55-
std::cout << "invoked const S.f()" << std::endl;
57+
void f() const {
58+
std::cout << "invoked const S.f()" << std::endl;
5659
}
57-
void f() volatile {
58-
std::cout << "invoked volatile S.f()" << std::endl;
60+
void f() volatile {
61+
std::cout << "invoked volatile S.f()" << std::endl;
5962
}
60-
void f() const volatile {
61-
std::cout << "invoked const volatile S.f()" << std::endl;
63+
void f() const volatile {
64+
std::cout << "invoked const volatile S.f()" << std::endl;
6265
}
6366
};
6467

6568
template <class T>
6669
void invoke() {
6770
T t;
68-
((T *)&t)->f();
71+
((T *)&t)->f();
6972
}
7073

7174
int main()
@@ -74,21 +77,23 @@ int main()
7477
invoke<std::add_const<S>::type>();
7578
invoke<std::add_volatile<S>::type>();
7679
invoke<std::add_cv<S>::type>();
77-
}
78-
```
79-
80-
```Output
80+
}
81+
```
82+
83+
```Output
8184
invoked non-cv-qualified S.f()
8285
invoked const S.f()
8386
invoked volatile S.f()
84-
invoked const volatile S.f()
85-
```
86-
87-
## Requirements
88-
**Header:** \<type_traits>
89-
**Namespace:** std
90-
91-
## See Also
92-
[<type_traits>](../standard-library/type-traits.md)
93-
[remove_const Class](../standard-library/remove-const-class.md)
94-
[remove_volatile Class](../standard-library/remove-volatile-class.md)
87+
invoked const volatile S.f()
88+
```
89+
90+
## Requirements
91+
92+
**Header:** \<type_traits>
93+
**Namespace:** std
94+
95+
## See also
96+
97+
[<type_traits>](../standard-library/type-traits.md)<br/>
98+
[remove_const Class](../standard-library/remove-const-class.md)<br/>
99+
[remove_volatile Class](../standard-library/remove-volatile-class.md)<br/>

0 commit comments

Comments
 (0)