Skip to content

Repo sync for protected CLA branch #3991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
---
description: "Learn more about: Compiler Warning (Level 1) C4743"
title: "Compiler Warning (Level 1) C4743"
ms.date: "05/13/2019"
ms.date: 06/16/2022
f1_keywords: ["C4743"]
helpviewer_keywords: ["C4743"]
ms.assetid: 2ee76ea3-77f3-4c2f-9a57-0751823c89fd
---
# Compiler Warning (Level 1) C4743

'*type*' has different size in '*file1*' and '*file2*': *number* and *number* bytes
> '*type*' has different size in '*file1*' and '*file2*': *size_1* and *size_2* bytes

An external variable referenced or defined in two files has different types in those files, and the compiler determined that the size of the variable in *file1* differs from the size of the variable in *file2*.

## Remarks

There is an important case when this warning can be emitted for C++. If you declare the same types with the same name in two different files, if those declarations contain virtual functions, and if the declarations are not the same, then the compiler can emit warning C4744 for the virtual function tables. The warning occurs because there are two different-sized virtual function tables for the same type, and linker must choose one of them to incorporate into the executable. It is possible that it can result in your program calling the wrong virtual function.
There's an important case when this warning can be emitted for C++. If you declare class types with the same name in two different files, if those declarations contain virtual functions, and if the declarations aren't the same, then the compiler can emit warning C4744 for the virtual function tables. The warning occurs because there are two different-sized virtual function tables for the same type, and the linker must choose one of them to incorporate into the executable. It's possible that it can result in your program calling the wrong virtual function.

To resolve this warning, either use the same type definition or use different names for the types or variables.

## Example

The following sample generates C4743. To compile it, place both files in the same folder, then run
The following sample generates C4743. To compile it, place both files in the same folder, then run this command in a developer command prompt:

```cmd
cl /EHsc /W1 /GL /O2 C4743a.cpp C4743b.cpp
```

Source file *`C4743a.cpp`*:

```cpp
// C4743a.cpp
class C {
Expand All @@ -41,6 +43,8 @@ void C::f3(void) {}
C q;
```

Source file *`C4743b.cpp`*:

```cpp
// C4743b.cpp
class C {
Expand All @@ -58,3 +62,5 @@ C x;

int main() {}
```

To resolve this issue, rename one of the `C` classes.
8 changes: 5 additions & 3 deletions docs/standard-library/error-category-class.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
description: "Learn more about: error_category Class"
title: "error_category Class"
ms.date: "11/04/2016"
ms.date: 06/15/2022
f1_keywords: ["system_error/std::error_category", "system_error/std::error_category::value_type", "system_error/std::error_category::default_error_condition", "system_error/std::error_category::equivalent", "system_error/std::error_category::message", "system_error/std::error_category::name"]
helpviewer_keywords: ["std::error_category", "std::error_category::value_type", "std::error_category::default_error_condition", "std::error_category::equivalent", "std::error_category::message", "std::error_category::name"]
ms.assetid: e0a71e14-852d-4905-acd6-5f8ed426706d
ms.custom: devdivchpfy22
---

# error_category Class

Represents the abstract, common base for objects that describes a category of error codes.
Expand Down Expand Up @@ -162,7 +164,7 @@ The object to be tested for equality.

#### Return Value

**`true`** if the objects are equal; **`false`** if the objects are not equal.
**`true`** if the objects are equal; **`false`** if the objects aren't equal.

#### Remarks

Expand All @@ -183,7 +185,7 @@ The object to be tested for inequality.

#### Return Value

**`true`** if the `error_category` object is not equal to the `error_category` object passed in *right*; otherwise **`false`**.
**`true`** if the `error_category` object isn't equal to the `error_category` object passed in *right*; otherwise **`false`**.

#### Remarks

Expand Down
22 changes: 12 additions & 10 deletions docs/standard-library/forward-list-class.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
description: "Learn more about: forward_list Class"
title: "forward_list Class"
ms.date: "11/04/2016"
ms.date: 06/15/2022
f1_keywords: ["forward_list/std::forward_list", "forward_list/std::forward_list::allocator_type", "forward_list/std::forward_list::const_iterator", "forward_list/std::forward_list::const_pointer", "forward_list/std::forward_list::const_reference", "forward_list/std::forward_list::difference_type", "forward_list/std::forward_list::iterator", "forward_list/std::forward_list::pointer", "forward_list/std::forward_list::reference", "forward_list/std::forward_list::size_type", "forward_list/std::forward_list::value_type", "forward_list/std::forward_list::assign", "forward_list/std::forward_list::before_begin", "forward_list/std::forward_list::begin", "forward_list/std::forward_list::cbefore_begin", "forward_list/std::forward_list::cbegin", "forward_list/std::forward_list::cend", "forward_list/std::forward_list::clear", "forward_list/std::forward_list::emplace_after", "forward_list/std::forward_list::emplace_front", "forward_list/std::forward_list::empty", "forward_list/std::forward_list::end", "forward_list/std::forward_list::erase_after", "forward_list/std::forward_list::front", "forward_list/std::forward_list::get_allocator", "forward_list/std::forward_list::insert_after", "forward_list/std::forward_list::max_size", "forward_list/std::forward_list::merge", "forward_list/std::forward_list::pop_front", "forward_list/std::forward_list::push_front", "forward_list/std::forward_list::remove", "forward_list/std::forward_list::remove_if", "forward_list/std::forward_list::resize", "forward_list/std::forward_list::reverse", "forward_list/std::forward_list::sort", "forward_list/std::forward_list::splice_after", "forward_list/std::forward_list::swap", "forward_list/std::forward_list::unique"]
helpviewer_keywords: ["std::forward_list", "std::forward_list::allocator_type", "std::forward_list::const_iterator", "std::forward_list::const_pointer", "std::forward_list::const_reference", "std::forward_list::difference_type", "std::forward_list::iterator", "std::forward_list::pointer", "std::forward_list::reference", "std::forward_list::size_type", "std::forward_list::value_type", "std::forward_list::assign", "std::forward_list::before_begin", "std::forward_list::begin", "std::forward_list::cbefore_begin", "std::forward_list::cbegin", "std::forward_list::cend", "std::forward_list::clear", "std::forward_list::emplace_after", "std::forward_list::emplace_front", "std::forward_list::empty", "std::forward_list::end", "std::forward_list::erase_after", "std::forward_list::front", "std::forward_list::get_allocator", "std::forward_list::insert_after", "std::forward_list::max_size", "std::forward_list::merge", "std::forward_list::pop_front", "std::forward_list::push_front", "std::forward_list::remove", "std::forward_list::remove_if", "std::forward_list::resize", "std::forward_list::reverse", "std::forward_list::sort", "std::forward_list::splice_after", "std::forward_list::swap", "std::forward_list::unique"]
ms.custom: devdivchpfy22
---

# forward_list Class

Describes an object that controls a varying-length sequence of elements. The sequence is stored as a singly-linked list of nodes, each containing a member of type `Type`.
Expand Down Expand Up @@ -32,7 +34,7 @@ A `forward_list` object allocates and frees storage for the sequence it controls
> [!NOTE]
> The stored allocator object is not copied when the container object is assigned.

Iterators, pointers and references might become invalid when elements of their controlled sequence are erased through `forward_list`. Insertions and splices performed on the controlled sequence through `forward_list` do not invalidate iterators.
Iterators, pointers and references might become invalid when elements of their controlled sequence are erased through `forward_list`. Insertions and splices performed on the controlled sequence through `forward_list` don't invalidate iterators.

Additions to the controlled sequence might occur by calls to [forward_list::insert_after](#insert_after), which is the only member function that calls the constructor `Type(const T&)`. `forward_list` might also call move constructors. If such an expression throws an exception, the container object inserts no new elements and rethrows the exception. Thus, an object of type `forward_list` is left in a known state when such exceptions occur.

Expand Down Expand Up @@ -211,9 +213,9 @@ A **`const`** forward-access iterator that points at the first element of the ra

### Remarks

With the return value of `cbegin`, the elements in the range cannot be modified.
With the return value of `cbegin`, the elements in the range can't be modified.

You can use this member function in place of the `begin()` member function to guarantee that the return value is `const_iterator`. Typically, it's used in conjunction with the [auto](../cpp/auto-cpp.md) type deduction keyword, as shown in the following example. In the example, consider `Container` to be a modifiable (non- **`const`**) container of any kind that supports `begin()` and `cbegin()`.
You can use this member function in place of the `begin()` member function to guarantee that the return value is `const_iterator`. Typically, it's used with the [auto](../cpp/auto-cpp.md) type deduction keyword, as shown in the following example. In the example, consider `Container` to be a modifiable (non- **`const`**) container of any kind that supports `begin()` and `cbegin()`.

```cpp
auto i1 = Container.begin();
Expand All @@ -238,7 +240,7 @@ A forward-access iterator that points just beyond the end of the range.

`cend` is used to test whether an iterator has passed the end of its range.

You can use this member function in place of the `end()` member function to guarantee that the return value is `const_iterator`. Typically, it's used in conjunction with the [auto](../cpp/auto-cpp.md) type deduction keyword, as shown in the following example. In the example, consider `Container` to be a modifiable (non- **`const`**) container of any kind that supports `end()` and `cend()`.
You can use this member function in place of the `end()` member function to guarantee that the return value is `const_iterator`. Typically, it's used with the [auto](../cpp/auto-cpp.md) type deduction keyword, as shown in the following example. In the example, consider `Container` to be a modifiable (non- **`const`**) container of any kind that supports `end()` and `cend()`.

```cpp
auto i1 = Container.end();
Expand All @@ -248,7 +250,7 @@ auto i2 = Container.cend();
// i2 is Container<T>::const_iterator
```

The value returned by `cend` should not be dereferenced.
The value returned by `cend` shouldn't be dereferenced.

## <a name="clear"></a> clear

Expand All @@ -272,7 +274,7 @@ typedef implementation-defined const_iterator;

### Remarks

`const_iterator` describes an object that can serve as a constant forward iterator for the controlled sequence. It is described here as a synonym for an implementation-defined type.
`const_iterator` describes an object that can serve as a constant forward iterator for the controlled sequence. It's described here as a synonym for an implementation-defined type.

## <a name="const_pointer"></a> const_pointer

Expand Down Expand Up @@ -457,7 +459,7 @@ The initializer_list to copy.

### Remarks

All constructors store an [allocator](../standard-library/allocator-class.md) and initialize the controlled sequence. The allocator object is the argument *Al*, if present. For the copy constructor, it is `right.get_allocator()`. Otherwise, it is `Allocator()`.
All constructors store an [allocator](../standard-library/allocator-class.md) and initialize the controlled sequence. The allocator object is the argument *Al*, if present. For the copy constructor, it's `right.get_allocator()`. Otherwise, it's `Allocator()`.

The first two constructors specify an empty initial controlled sequence.

Expand Down Expand Up @@ -561,7 +563,7 @@ typedef implementation-defined iterator;

### Remarks

`iterator` describes an object that can serve as a forward iterator for the controlled sequence. It is described here as a synonym for an implementation-defined type.
`iterator` describes an object that can serve as a forward iterator for the controlled sequence. It's described here as a synonym for an implementation-defined type.

## <a name="max_size"></a> max_size

Expand Down Expand Up @@ -926,7 +928,7 @@ The forward list providing the elements to be exchanged.

### Remarks

The member function swaps the controlled sequences between **`*this`** and *right*. If `get_allocator() == right.get_allocator()`, it does so in constant time, it throws no exceptions, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
The member function swaps the controlled sequences between **`*this`** and *right*. If `get_allocator() == right.get_allocator()`, it does so in constant time, it throws no exceptions, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. Otherwise, it performs element assignments and constructor calls proportional to the number of elements in the two controlled sequences.

## <a name="unique"></a> unique

Expand Down
18 changes: 10 additions & 8 deletions docs/standard-library/fpos-class.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
description: "Learn more about: fpos Class"
title: "fpos Class"
ms.date: "03/27/2019"
ms.date: 06/15/2022
f1_keywords: ["iosfwd/std::fpos", "iosfwd/std::fpos::seekpos", "iosfwd/std::fpos::state", "iosfwd/std::fpos::operator streamoff"]
helpviewer_keywords: ["std::fpos [C++]", "std::fpos [C++], seekpos", "std::fpos [C++], state"]
ms.assetid: ffd0827c-fa34-47f4-b10e-5cb707fcde47
ms.custom: devdivchpfy22
---

# fpos Class

The class template describes an object that can store all the information needed to restore an arbitrary file-position indicator within any stream. An object of class fpos\< **St**> effectively stores at least two member objects:
Expand Down Expand Up @@ -38,7 +40,7 @@ State information.

|Member function|Description|
|-|-|
|[seekpos](#seekpos)|Used internally by the C++ Standard Library only. Do not call this method from your code.|
|[seekpos](#seekpos)|Used internally by the C++ Standard Library only. Don't call this method from your code.|
|[state](#state)|Sets or returns the conversion state.|

### Operators
Expand Down Expand Up @@ -82,7 +84,7 @@ The offset into the stream.

### Remarks

The first constructor stores the offset *_Off*, relative to the beginning of file and in the initial conversion state (if that matters). If *_Off* is -1, the resulting object represents an invalid stream position.
The first constructor stores the offset *_Off*, relative to the beginning of file and in the initial conversion state. If *_Off* is -1, the resulting object represents an invalid stream position.

The second constructor stores a zero offset and the object *_State*.

Expand All @@ -101,7 +103,7 @@ The file-position indicator against which to compare.

### Return Value

**`true`** if the file-position indicators are not equal, otherwise **`false`**.
**`true`** if the file-position indicators aren't equal, otherwise **`false`**.

### Remarks

Expand Down Expand Up @@ -178,7 +180,7 @@ The position in the file.

### Remarks

The member function returns **fpos(\*this) +=** `_Off`.
The member function returns **`fpos(*this) +=_Off`**.

### Example

Expand All @@ -203,7 +205,7 @@ The position in the file.

### Remarks

The member function adds *_Off* to the stored offset member object and then returns **\*this**. For positioning within a file, the result is generally valid only for binary streams that do not have a state-dependent encoding.
The member function adds *_Off* to the stored offset member object and then returns **`*this`**. When working with files, the result is valid only for binary streams that don't have a state-dependent encoding.

### Example

Expand Down Expand Up @@ -254,7 +256,7 @@ The member function returns `fpos(*this) -= _Off`.

### Remarks

For positioning within a file, the result is generally valid only for binary streams that do not have a state-dependent encoding.
When working with files, the result is valid only for binary streams that don't have a state-dependent encoding.

### Example

Expand Down Expand Up @@ -326,7 +328,7 @@ int main( )

## <a name="seekpos"></a> fpos::seekpos

This method is used internally by the C++ Standard Library only. Do not call this method from your code.
This method is used internally by the C++ Standard Library only. Don't call this method from your code.

```cpp
fpos_t seekpos() const;
Expand Down
10 changes: 6 additions & 4 deletions docs/standard-library/front-insert-iterator-class.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
description: "Learn more about: front_insert_iterator Class"
title: "front_insert_iterator Class"
ms.date: "11/04/2016"
ms.date: 06/15/2022
f1_keywords: ["iterator/std::front_insert_iterator", "iterator/std::front_insert_iterator::container_type", "iterator/std::front_insert_iterator::reference"]
helpviewer_keywords: ["std::front_insert_iterator [C++]", "std::front_insert_iterator [C++], container_type", "std::front_insert_iterator [C++], reference"]
ms.assetid: a9a9c075-136a-4419-928b-c4871afa033c
ms.custom: devdivchpfy22
---

# front_insert_iterator Class

Describes an iterator adaptor that satisfies the requirements of an output iterator. It inserts, rather than overwrites, elements into the front of a sequence and thus provides semantics that are different from the overwrite semantics provided by the iterators of the C++ sequence containers. The `front_insert_iterator` class is templatized on the type of container.
Describes an iterator adaptor that satisfies the requirements of an output iterator. It inserts, rather than overwrites, elements into the front of a sequence. Thus it provides semantics that are different from the overwrite semantics provided by the iterators of the C++ sequence containers. The `front_insert_iterator` class is templatized on the type of container.

## Syntax

Expand All @@ -24,7 +26,7 @@ The type of container into the front of which elements are to be inserted by a `

## Remarks

The container must satisfy the requirements for a front insertion sequence where is it possible to insert elements at the beginning of the sequence in amortized constant time. The C++ Standard Library sequence containers defined by the [deque Class](../standard-library/deque-class.md) and [list Class](../standard-library/list-class.md) provide the needed `push_front` member function and satisfy these requirements. By contrast, sequence containers defined by the [vector Class](../standard-library/vector-class.md) do not satisfy these requirements and cannot be adapted to use with `front_insert_iterator`s. A `front_insert_iterator` must always be initialized with its container.
The container must satisfy the requirements for a front insertion sequence where is it possible to insert elements at the beginning of the sequence in amortized constant time. The C++ Standard Library sequence containers defined by the [deque Class](../standard-library/deque-class.md) and [list Class](../standard-library/list-class.md) provide the needed `push_front` member function and satisfy these requirements. By contrast, sequence containers defined by the [vector Class](../standard-library/vector-class.md) don't satisfy these requirements and can't be adapted to use with `front_insert_iterator`s. A `front_insert_iterator` must always be initialized with its container.

### Constructors

Expand Down Expand Up @@ -172,7 +174,7 @@ The member function returns the value of the element addressed.

### Remarks

Used to implement the output iterator expression **\*Iter** = **value**. If `Iter` is an iterator that addresses an element in a sequence, then **\*Iter** = **value** replaces that element with value and does not change the total number of elements in the sequence.
Used to implement the output iterator expression **\*Iter** = **value**. If `Iter` is an iterator that addresses an element in a sequence, then **\*Iter** = **value** replaces that element with value and doesn't change the total number of elements in the sequence.

### Example

Expand Down
Loading