Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 1.07 KB

File metadata and controls

22 lines (17 loc) · 1.07 KB
description Learn more about: C26455 DEFAULT_CTOR_NOEXCEPT
title C26455
ms.date 12/14/2018
ms.topic conceptual
f1_keywords
C26455
helpviewer_keywords
C26455
ms.assetid 27e86063-d969-49d8-8912-dcc2dc57249f
author kylereedmsft
ms.author kylereed

C26455 DEFAULT_CTOR_NOEXCEPT

The C++ Core Guidelines suggest that default constructors shouldn't do anything that can throw. If the default constructor is allowed to throw, operations such as move and swap will also throw which is undesirable because move and swap should always succeed. Parameterized constructors may throw.

Remarks

Consider the default constructors of the STL types, like std::vector. In these implementations, the default constructors initialize internal state without making allocations. In the std::vector case, the size is set to 0 and the internal pointer is set to nullptr. The same pattern should be followed for all default constructors.

See also