Skip to content
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
12 changes: 6 additions & 6 deletions docs/cpp/void-cpp.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
description: "Learn more about: void (C++)"
title: "void (C++)"
ms.date: "11/04/2016"
ms.date: 10/15/2021
f1_keywords: ["void_cpp"]
helpviewer_keywords: ["void keyword [C++]", "functions [C++], void", "pointers, void"]
ms.assetid: d203edba-38e6-4056-8b89-011437351057
---
# void (C++)

When used as a function return type, the **`void`** keyword specifies that the function does not return a value. When used for a function's parameter list, **`void`** specifies that the function takes no parameters. When used in the declaration of a pointer, **`void`** specifies that the pointer is "universal."
When used as a function return type, the **`void`** keyword specifies that the function doesn't return a value. When used for a function's parameter list, **`void`** specifies that the function takes no parameters. When used in the declaration of a pointer, **`void`** specifies that the pointer is "universal."

If a pointer's type is **void\***, the pointer can point to any variable that is not declared with the **`const`** or **`volatile`** keyword. A **void\*** pointer cannot be dereferenced unless it is cast to another type. A **void\*** pointer can be converted into any other type of data pointer.
If a pointer's type is `void*`, the pointer can point to any variable that's not declared with the **`const`** or **`volatile`** keyword. A `void*` pointer can't be dereferenced unless it's cast to another type. A `void*` pointer can be converted into any other type of data pointer.

A **`void`** pointer can point to a function, but not to a class member in C++.
In C++, a **`void`** pointer can point to a free function (a function that's not a member of a class), or to a static member function, but not to a non-static member function.

You cannot declare a variable of type **`void`**.
You can't declare a variable of type **`void`**.

## Example

Expand All @@ -32,5 +32,5 @@ int main() {

## See also

[Keywords](../cpp/keywords-cpp.md)<br/>
[Keywords](../cpp/keywords-cpp.md)\
[Built-in types](../cpp/fundamental-types-cpp.md)
2 changes: 0 additions & 2 deletions docs/mfc/codesnippet/CPP/cfindreplacedialog-class_5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ LRESULT CMyRichEditView::OnFindReplace(WPARAM wparam, LPARAM lparam)
_T("FindString"), csFindString));
VERIFY(AfxGetApp()->WriteProfileString(AfxGetApp()->m_pszAppName,
_T("ReplaceString"), csReplaceString));

VERIFY(pDlg->DestroyWindow());
}
}

Expand Down
4 changes: 0 additions & 4 deletions docs/mfc/reference/cfindreplacedialog-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ BOOL IsTerminating() const;

Nonzero if the user has decided to terminate the dialog box; otherwise 0.

### Remarks

If this function returns nonzero, you should call the `DestroyWindow` member function of the current dialog box and set any dialog box pointer variable to NULL. Optionally, you can also store the find/replace text last entered and use it to initialize the next find/replace dialog box.

### Example

See the example for [CFindReplaceDialog::GetFindString](#getfindstring).
Expand Down
2 changes: 1 addition & 1 deletion docs/standard-library/choose-enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If a `local_time` specifies a time during this "extra" hour, it isn't clear how

**Nonexistent conversion error**

When converting from standard time to daylight saving time, a different problem can arise. During the transition from standard time to daylight saving time in the spring, clocks move ahead an hour. The skipped hour disappears, so even though it appears that we've added an hour to the time, by "springing forward" an hour, the hour following the transition is effectively removed.
When converting from standard time to daylight saving time, a different problem can arise. During the transition from standard time to daylight saving time in the spring, clocks move ahead an hour. The skipped hour disappears, so even though it appears we've added an hour to the time, by "springing forward" an hour, the hour following the transition is effectively removed.

Consider the change to daylight saving time in New York, which happens on the second Sunday in March at 2am. At 2am, the clock transitions to daylight savings time and now reads 3:00am. If the `local_time` being converted is 2:30am, for example, that time is during the period that was "removed" and so is "nonexistent", resulting in a [`nonexistent_local_time`](nonexistent-local-time.md#example-nonexistent_local_time) exception.

Expand Down
83 changes: 80 additions & 3 deletions docs/standard-library/chrono-functions.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
description: "Learn more about: <chrono> functions"
title: "<chrono> functions"
ms.date: 10/06/2021
f1_keywords: ["chrono/std::duration_cast", "chrono/std::time_point_cast", "chrono/std::chrono::duration_cast", "chrono/std::chrono::time_point_cast", "chrono/std::chrono::from_stream", "chrono/std::chrono::abs", "chrono/std::chrono::floor", "chrono/std::chrono::ceil", "chrono/std::chrono::round", "chrono/std::chrono::is_am", "chrono/std::chrono::is_pm", "chrono/std::chrono::make12", "chrono/std::chrono::make24", "chrono/std::chrono::get_leap_second_info", "chrono/std::chrono::get_tzdb", "chrono/std::chrono::get_tzdb_list", "chrono/std::chrono::locate_zone", "chrono/std::chrono::current_zone", "chrono/std::chrono::reload_tzdb", "chrono/std::chrono::remote_version"]
helpviewer_keywords: ["std::duration_cast function", "std::time_point_cast function", "std::chrono::duration_cast function", "std::chrono::time_point_cast function", "std::chrono::from_stream function", "std::chrono::floor function", "std::chrono::ceil function", "std::chrono::round function", "std::chrono::is_am function", "std::chrono::is_pm function", "std::chrono::make12 function", "std::chrono::make24 function", "std::chrono::get_leap_second_info function", "std::chrono::get_tzdb function", "std::chrono::get_tzdb_list function", "std::chrono::locate_zone function", "std::chrono::current_zone function", "std::chrono::reload_tzdb function", "std::chrono::remote_version function"]
ms.date: 10/15/2021
f1_keywords: ["chrono/std::duration_cast", "chrono/std::time_point_cast", "chrono/std::chrono::clock_cast", "chrono/std::chrono::duration_cast", "chrono/std::chrono::time_point_cast", "chrono/std::chrono::from_stream", "chrono/std::chrono::abs", "chrono/std::chrono::floor", "chrono/std::chrono::ceil", "chrono/std::chrono::round", "chrono/std::chrono::is_am", "chrono/std::chrono::is_pm", "chrono/std::chrono::make12", "chrono/std::chrono::make24", "chrono/std::chrono::get_leap_second_info", "chrono/std::chrono::get_tzdb", "chrono/std::chrono::get_tzdb_list", "chrono/std::chrono::locate_zone", "chrono/std::chrono::current_zone", "chrono/std::chrono::reload_tzdb", "chrono/std::chrono::remote_version"]
helpviewer_keywords: ["std::duration_cast function", "std::time_point_cast function", "std::chrono::clock_cast", "std::chrono::duration_cast function", "std::chrono::time_point_cast function", "std::chrono::from_stream function", "std::chrono::floor function", "std::chrono::ceil function", "std::chrono::round function", "std::chrono::is_am function", "std::chrono::is_pm function", "std::chrono::make12 function", "std::chrono::make24 function", "std::chrono::get_leap_second_info function", "std::chrono::get_tzdb function", "std::chrono::get_tzdb_list function", "std::chrono::locate_zone function", "std::chrono::current_zone function", "std::chrono::reload_tzdb function", "std::chrono::remote_version function"]
---

# `<chrono>` functions
Expand Down Expand Up @@ -120,6 +120,83 @@ Returns the smallest time point representable using `ToDuration` that's greater

`ceil` doesn't participate in overload resolution unless the `ToDuration` type is an instance of a [`duration`](../standard-library/duration-class.md).

## <a name="std-chrono-clock-cast"></a> `clock_cast`

Converts a [`time_point`](time-point-class.md) for one clock to an equivalent `time_point` for another clock.

### Syntax

```cpp
template <class DestClock, class SourceClock, class Duration>
auto clock_cast(const time_point<SourceClock, Duration>& t); // C++ 20
```

### Parameters

*`DestClock`*\
The clock type to convert the `time_point` to.

*`Duration`*\
The [`duration`](duration-class.md) of the `SourceClock`, or one that you specify.

*`SourceClock`*\
The clock type that the `time_point` to convert is based on.

*`t`*\
The `time_point` to convert.

### Return value

A [`time_point`](time-point-class.md) equivalent to **`t`**, but specific to `DestClock`.

### Remarks

The parameters `SourceClock` and `Duration` can be inferred via class template argument deduction when not explicitly passed. For example, given `clock_cast<utc_clock>(file_clock::now())`, `SourceClock` is deduced to be `file_clock`, and `Duration` is deduced to be `file_clock::duration`.

From the following list of well-formed clock conversions, the one that requires the fewest conversion steps to get from the `SourceClock` to the `DestClock` is selected.

```cpp
clock_time_conversion<DestClock, SourceClock>{}(t)

clock_time_conversion<DestClock, system_clock>{}(
clock_time_conversion<system_clock, SourceClock>{}(t))

clock_time_conversion<DestClock, utc_clock>{}(
clock_time_conversion<utc_clock, SourceClock>{}(t))

clock_time_conversion<DestClock, utc_clock>{}(
clock_time_conversion<utc_clock, system_clock>{}(
clock_time_conversion<system_clock, SourceClock>{}(t)))

clock_time_conversion<DestClock, system_clock>{}(
clock_time_conversion<system_clock, utc_clock>{}(
clock_time_conversion<utc_clock, SourceClock>{}(t)))
```

For more information about what `clock_time_conversion` does, see [`clock_time_conversion` struct](clock-time-conversion-struct.md).

### Example `clock_cast`

```cpp
// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
utc_clock::time_point t = clock_cast<utc_clock>(file_clock::now());
std::cout << t;

return 0;
}
```

```output
2021-10-11 22:58:17.8540720
```

## <a name="std-chrono-current-zone"></a> `current_zone`

Gets the current time zone object.
Expand Down
11 changes: 8 additions & 3 deletions docs/standard-library/chrono.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: <chrono>"
title: "<chrono>"
ms.date: 09/30/2021
ms.date: 10/13/2021
f1_keywords: ["<chrono>", "chrono/std::chrono::nanoseconds", "chrono/std::chrono::minutes", "chrono/std::chrono::seconds", "chrono/std::chrono::hours", "chrono/std::chrono::milliseconds", "chrono/std::chrono::microseconds"]
---

Expand Down Expand Up @@ -70,7 +70,10 @@ In the Microsoft C++ implementation, `steady_clock::time_point` is now a `typede
| [`sys_info`](sys-info-struct.md) | Provides a low-level interface to time zone information about the result of converting a `sys_time` to a `local_time`. |
| [`time_zone` class](time-zone-class.md) | All time zone transitions for a specific geographic area. |
| [`time_zone_link` class](time-zone-link-class.md) | An alternative name for a `time_zone`. |
| [`tzdb` struct](tzdb-struct.md) | Represents a copy of the time zone database. |
| [`tzdb_list` class](tzdb-list-class.md) | A singleton list of time zone databases. |
| [`zoned_time` class](zoned-time-class.md) | A pairing of a [`time_zone`](time-zone-class.md) and a [`time_point`](time-point-class.md) with a specified precision. |
| [`zoned_traits` struct](zoned-traits-struct.md) | Used to associate a different default time zone with a `zoned_time`, and optionally map a custom name to that default time zone. |

**Exceptions**

Expand All @@ -85,6 +88,7 @@ In the Microsoft C++ implementation, `steady_clock::time_point` is now a `typede
|--|--|
| [`ceil(duration)`](chrono-functions.md#std-chrono-ceil-duration) | Returns the `ceil` of a `duration` object as a specified type. |
| [`ceil(time_point)`](chrono-functions.md#std-chrono-ceil-time-point) | Returns the `ceil` of a `time_point` object as a specified type. |
| [`clock_cast`](chrono-functions.md#std-chrono-clock-cast) | Converts a [`time_point`](time-point-class.md) from one clock to an equivalent `time_point` for another clock. |
| [`duration_cast`](chrono-functions.md#std-chrono-duration-cast) | Casts a `duration` object to a specified type. |
| [`floor(duration)`](chrono-functions.md#std-chrono-floor-duration) | Returns the `floor` of a `duration` object as a specified type. |
| [`floor(time_point)`](chrono-functions.md#std-chrono-floor-time-point) | Returns the `floor` of a `time_point` object as a specified type. |
Expand All @@ -104,8 +108,8 @@ In the Microsoft C++ implementation, `steady_clock::time_point` is now a `typede
| Name | Description |
|--|--|
| [`current_zone`](chrono-functions.md#std-chrono-current-zone) | Gets the current time zone. |
| [`get_tzdb_list`](chrono-functions.md#std-chrono-get-tzdb-list) | Gets the list of time zone database entries. |
| [`get_tzdb`](chrono-functions.md#std-chrono-get-tzdb) | Gets the first time zone database entry. |
| [`get_tzdb_list`](chrono-functions.md#std-chrono-get-tzdb-list) | Gets the list of time zone database entries. |
| [`reload_tzdb`](chrono-functions.md#std-chrono-reload-tzdb) | Gets an updated time zone database entry. |
| [`remote_version`](chrono-functions.md#std-chrono-remote-version) | Checks for an updated time zone database entry. |

Expand Down Expand Up @@ -163,6 +167,7 @@ For more information about ratio types that are used in the following typedefs,

| Name | Description |
|--|--|
| [`clock_time_conversion`](clock-time-conversion-struct.md) | A trait that specifies how to convert a [`time_point`](time-point-class.md) from one clock to another. |
| [is_clock](is-clock-struct.md) | Check if a type is a clock. |
| [treat_as_floating_point](treat-as-floating-point-structure.md) | Check if a `duration` can be converted to another `duration` that has a different tick period. |

Expand All @@ -185,7 +190,7 @@ For more information about ratio types that are used in the following typedefs,
| `nanoseconds operator "" ns(unsigned long long Val)` | Specifies nanoseconds as an integral value. |
| `duration<double, nano> operator "" ns(long double Val)` | Specifies nanoseconds as a floating-point value. |

The following examples show how to use `<chrono>` literals.
The following examples show how to use `<chrono>` literals:

```cpp
constexpr auto day = 24h;
Expand Down
157 changes: 157 additions & 0 deletions docs/standard-library/clock-time-conversion-struct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
description: "Learn more about clock_conversion trait"
title: "clock_conversion struct"
ms.date: 10/12/2021
f1_keywords: ["chrono/std::clock_conversion"]
helpviewer_keywords: ["std::chrono [C++], clock_conversion"]
---

# `clock_time_conversion` struct

A trait that specifies how to convert a [`time_point`](time-point-class.md) from one type of clock to another, while maintaining the equivalent point in time.

## Syntax

```cpp
// C++20
1) template<class Dest, class Source> struct clock_time_conversion {};
2) template<class Clock> struct clock_time_conversion<Clock, Clock>;
3) template<> struct clock_time_conversion<system_clock, system_clock>;
4) template<> struct clock_time_conversion<utc_clock, utc_clock>;
5) template<> struct clock_time_conversion<system_clock, utc_clock>;
6) template<> struct clock_time_conversion<utc_clock, system_clock>;
7) template<class Clock> struct clock_time_conversion<Clock, system_clock>;
8) template<class Clock> struct clock_time_conversion<system_clock, Clock>;
9) template<class Clock> struct clock_time_conversion<Clock, utc_clock>;
10) template<class Clock> struct clock_time_conversion<utc_clock, Clock>;
```

### Template parameters

*`Clock`*\
A clock type to convert from/to.

*`Dest`*\
The clock type to convert to.

*`Source`*\
The clock type to convert from.

The traits provide the following conversions:

1\) An empty struct that is defined only so that it can be specialized.\
2-4\) Identity conversions. Returns the same clock you pass in.\
5-6\) Converting between `sys_time` and `utc_time` calls `utc_clock::to_sys` or `utc_clock::from_sys` depending on the direction of the conversion.\
7-8\) Converting between `sys_time` and the specified clock, when the specified clock supports `to_sys` and `from_sys`, results in a call to `Clock::to_sys` or `Clock::from_sys`, depending on the direction of the conversion.\
9-10\) Converting between `utc_time`and the specified clock, when the specified clock supports `from_utc` and `to_sys`, results in a call to `Clock::to_utc` or `Clock::from_utc`, depending on the direction of the conversion.

## Members

|Name|Description|
|----------|-----------------|
| [`operator ()`](#op_parens) | Converts a `time_point` from one clock to another. |

## Remarks

You usually won't use this trait directly in your code. It's used by the [`clock_cast`](chrono-functions.md#std-chrono-clock-cast) conversion function.

## Requirements

**Header:** \<`chrono`>

**Namespace:** `std`

**Compiler Option:** [`/std:c++latest`](../build/reference/std-specify-language-standard-version.md)

## <a name="op_parens"></a> `operator()`

Converts a `time_point` from one clock type to another while maintaining the equivalent point in time.

### Syntax

```cpp
1)
template <class Duration>
time_point<Clock, Duration> operator()(const time_point<Clock, Duration>& t) const;

2)
template <class Duration>
sys_time<Duration> operator()(const sys_time<Duration> & t) const;

3)
template <class Duration>
utc_time<Duration> operator()(const utc_time<Duration>& t) const;

4)
template <class Duration>
sys_time<Duration> operator()(const utc_time<Duration>& t) const;

5)
template <class Duration>
utc_time<Duration> operator()(const sys_time<Duration>& t) const;
```

### Parameters

**`t`**
The `time_point` to convert.

### Return value

1-3\) Identity conversions. No conversion. Returns `t` without any changes.\
4\) Returns `utc_clock::to_sys(t)`.\
5\) Returns` utc_clock::from_sys(t)`.

### Deduction guides

The following deduction guides are provided for `template <class Duration> operator()`:

```cpp
1)
template <class Duration> auto operator()(const sys_time<Duration>& t) const
-> decltype(Clock::from_sys(t));

2)
template <class Duration> auto operator()(const time_point<SourceClock, Duration>& t) const
-> decltype(Clock::to_sys(t));

3)
template <class Duration> auto operator()(const utc_time<Duration>& t) const
-> decltype(Clock::from_utc(t));

4)
template <class Duration> auto operator()(const time_point<Clock, Duration>& t) const
-> decltype(Clock::to_utc(t));
```

1\) Participates in overload resolution only when `Clock` supports `from_sys()` and returns `time_point<Clock, Duration>`.\
2\) Participates in overload resolution only when `Clock` supports `to_sys()` and returns `sys_time<Duration>`.\
3\) Participates in overload resolution only when `Clock` supports `from_utc()` and returns `time_point<Clock, Duration>`.\
4\) Participates in overload resolution only when `Clock` supports `to_utc()` and returns `utc_time<Duration>`.

## Example: `clock_time_conversion`

```cpp
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
auto sd = sys_days{ 2021y / July / 26 };
auto time = clock_time_conversion<utc_clock, system_clock>{}(sd);
std::cout << time << "\n";
return 0;
}
```

```output
2021-07-26 00:00:00
```

## See also

[`<chrono>`](chrono.md)\
[`clock_cast`](chrono-functions.md#std-chrono-clock-cast)\
[Header Files Reference](cpp-standard-library-header-files.md)
2 changes: 1 addition & 1 deletion docs/standard-library/day-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Represents a day of the month. For example, the 25th day of the month.
## Syntax

```cpp
class day; // c++ 20
class day; // C++ 20
```

## Remarks
Expand Down
Loading