Skip to content

Commit 12e6f23

Browse files
authored
Merge pull request #2502 from mikeblome/mb-type-system
moved type system topics out of modern c++
2 parents 6529989 + 508521f commit 12e6f23

13 files changed

+32
-44
lines changed

docs/cpp/algorithms-modern-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ It's no secret that the old CRT `rand()` function has many flaws, which have bee
6969
7070
## See also
7171
72-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
72+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
7373
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
7474
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)<br/>

docs/cpp/containers-modern-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ For more information about containers, see [C++ Standard Library Containers](../
3434

3535
## See also
3636

37-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
37+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
3838
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
3939
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/cpp-type-system-modern-cpp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: "C++ Type System (Modern C++)"
3-
ms.date: "11/19/2018"
2+
title: "C++ type system"
3+
ms.date: "11/19/2019"
44
ms.topic: "conceptual"
55
ms.assetid: 553c0ed6-77c4-43e9-87b1-c903eec53e80
66
---
7-
# C++ Type System (Modern C++)
7+
# C++ type system
88

99
The concept of *type* is very important in C++. Every variable, function argument, and function return value must have a type in order to be compiled. Also, every expression (including literal values) is implicitly given a type by the compiler before it is evaluated. Some examples of types include **int** to store integral values, **double** to store floating-point values (also known as *scalar* data types), or the Standard Library class [std::basic_string](../standard-library/basic-string-class.md) to store text. You can create your own type by defining a **class** or **struct**. The type specifies the amount of memory that will be allocated for the variable (or expression result), the kinds of values that may be stored in that variable, how those values (as bit patterns) are interpreted, and the operations that can be performed on it. This article contains an informal overview of the major features of the C++ type system.
1010

@@ -162,6 +162,6 @@ For more information about the C++ type system, see the following topics.
162162

163163
## See also
164164

165-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
165+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
166166
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
167167
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/errors-and-exception-handling-modern-cpp.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ Exception specifications were introduced in C++ as a way to specify the exceptio
9494
9595
## See also
9696
97-
[How to: Interface Between Exceptional and Non-Exceptional Code](how-to-interface-between-exceptional-and-non-exceptional-code.md)<br/>
98-
[Welcome Back to C++ (Modern C++)](welcome-back-to-cpp-modern-cpp.md)<br/>
99-
[C++ Language Reference](cpp-language-reference.md)<br/>
97+
[How to: Interface Between Exceptional and Non-Exceptional Code](../cpp/how-to-interface-between-exceptional-and-non-exceptional-code.md)<br/>
98+
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
10099
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/object-lifetime-and-resource-management-modern-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ Use static lifetime sparingly (global static, function local static) because pro
7979
8080
## See also
8181
82-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
82+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
8383
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
8484
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/objects-own-resources-raii.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ void g() {
3333

3434
## See also
3535

36-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
36+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
3737
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
3838
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/pimpl-for-compile-time-encapsulation-modern-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ Consider whether to add support for non-throwing swap specialization.
5353

5454
## See also
5555

56-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
56+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
5757
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
5858
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/portability-at-abi-boundaries-modern-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ extern "C" { // functions using explicit "this"
2828
2929
## See also
3030
31-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
31+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
3232
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
3333
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/smart-pointers-modern-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,6 @@ Class that encapsulates methods for manipulating a list of `CAutoPtr` nodes.
110110

111111
## See also
112112

113-
[Welcome Back to C++ (Modern C++)](welcome-back-to-cpp-modern-cpp.md)<br/>
114-
[C++ Language Reference](cpp-language-reference.md)<br/>
113+
[Pointers](pointers-cpp.md)<br/>
114+
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
115115
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/string-and-i-o-formatting-modern-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The following code demonstrates some of the Boost formatting features.
6363

6464
## See also
6565

66-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
66+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
6767
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
6868
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)<br/>
6969
[\<iostream>](../standard-library/iostream.md)<br/>

docs/cpp/type-conversions-and-type-safety-modern-cpp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: "Type Conversions and Type Safety (Modern C++)"
3-
ms.date: "05/07/2019"
2+
title: "Type conversions and type safety"
3+
ms.date: "11/19/2019"
44
ms.topic: "conceptual"
55
ms.assetid: 629b361a-2ce1-4700-8b5d-ab4f57b245d5
66
---
7-
# Type Conversions and Type Safety (Modern C++)
7+
# Type conversions and type safety
88

99
This document identifies common type conversion problems and describes how you can avoid them in your C++ code.
1010

@@ -172,7 +172,7 @@ The C-style cast operator is identical to the call operator () and is therefore
172172

173173
## See also
174174

175-
[C++ Type System (Modern C++)](../cpp/cpp-type-system-modern-cpp.md)<br/>
176-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
175+
[C++ type system](../cpp/cpp-type-system-modern-cpp.md)<br/>
176+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
177177
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
178178
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/value-types-modern-cpp.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
---
2-
title: "Value Types (Modern C++)"
3-
ms.date: "05/07/2019"
2+
title: "C++ classes as value types"
3+
ms.date: "11/19/2019"
44
ms.topic: "conceptual"
55
ms.assetid: f63bb62c-60da-40d5-ac14-4366608fe260
66
---
7-
# Value Types (Modern C++)
7+
# C++ classes as value types
88

9-
C++ classes are by default value types. This topic provides an introductory overview of value types and issues relating to their use.
10-
11-
## Value vs. reference types
12-
13-
As previously stated, C++ classes are by default value types. They can be specified as reference types, which enable polymorphic behavior to support object-oriented programming. Value types are sometimes viewed from the perspective of memory and layout control, whereas reference types are about base classes and virtual functions for polymorphic purposes. By default, value types are copyable, which means there is always a copy constructor and a copy assignment operator. For reference types, you make the class non-copyable (disable the copy constructor and copy assignment operator) and use a virtual destructor, which supports their intended polymorphism. Value types are also about the contents, which, when they are copied, always give you two independent values that can be modified separately. Reference types are about identity - what kind of object is it? For this reason, "reference types" are also referred to as "polymorphic types".
9+
C++ classes are by default value types. They can be specified as reference types, which enable polymorphic behavior to support object-oriented programming. Value types are sometimes viewed from the perspective of memory and layout control, whereas reference types are about base classes and virtual functions for polymorphic purposes. By default, value types are copyable, which means there is always a copy constructor and a copy assignment operator. For reference types, you make the class non-copyable (disable the copy constructor and copy assignment operator) and use a virtual destructor, which supports their intended polymorphism. Value types are also about the contents, which, when they are copied, always give you two independent values that can be modified separately. Reference types are about identity - what kind of object is it? For this reason, "reference types" are also referred to as "polymorphic types".
1410

1511
If you really want a reference-like type (base class, virtual functions), you need to explicitly disable copying, as shown in the `MyRefType` class in the following code.
1612

@@ -104,13 +100,9 @@ If you enable copy construction/assignment, also enable move construction/assign
104100
105101
Some *non-value* types are move-only, such as when you can’t clone a resource, only transfer ownership. Example: `unique_ptr`.
106102
107-
## Section
108-
109-
Content
110-
111103
## See also
112104
113-
[C++ Type System (Modern C++)](../cpp/cpp-type-system-modern-cpp.md)<br/>
114-
[Welcome Back to C++ (Modern C++)](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
105+
[C++ type system](../cpp/cpp-type-system-modern-cpp.md)<br/>
106+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
115107
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
116108
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/toc.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,15 +3652,6 @@
36523652
items:
36533653
- name: Welcome back to C++ (Modern C++)
36543654
href: cpp/welcome-back-to-cpp-modern-cpp.md
3655-
- name: Type system (Modern C++)
3656-
expanded: false
3657-
items:
3658-
- name: Type system (Modern C++)
3659-
href: cpp/cpp-type-system-modern-cpp.md
3660-
- name: Value types (Modern C++)
3661-
href: cpp/value-types-modern-cpp.md
3662-
- name: Type conversions and type safety (Modern C++)
3663-
href: cpp/type-conversions-and-type-safety-modern-cpp.md
36643655
- name: Uniform initialization and delegating constructors
36653656
href: cpp/uniform-initialization-and-delegating-constructors.md
36663657
- name: Object lifetime and resource management (Modern C++)
@@ -3713,6 +3704,8 @@
37133704
- name: Declarations and definitions
37143705
expanded: false
37153706
items:
3707+
- name: C++ type system
3708+
href: cpp/cpp-type-system-modern-cpp.md
37163709
- name: Declarations and definitions
37173710
href: cpp/declarations-and-definitions-cpp.md
37183711
- name: Overview of declarators
@@ -3856,6 +3849,8 @@
38563849
href: cpp/floating-limits.md
38573850
- name: Standard conversions
38583851
href: cpp/standard-conversions.md
3852+
- name: Type conversions and type safety
3853+
href: cpp/type-conversions-and-type-safety-modern-cpp.md
38593854
- name: Built-in operators, precedence, and associativity
38603855
expanded: false
38613856
items:
@@ -4167,6 +4162,8 @@
41674162
href: cpp/special-member-functions.md
41684163
- name: Static members
41694164
href: cpp/static-members-cpp.md
4165+
- name: C++ classes as value types
4166+
href: cpp/value-types-modern-cpp.md
41704167
- name: User-defined type conversions
41714168
href: cpp/user-defined-type-conversions-cpp.md
41724169
- name: Mutable data members

0 commit comments

Comments
 (0)