Rename ptr.h to nonnull.h (#839)

This commit is contained in:
Jon Meow
2021-09-20 15:15:30 -07:00
committed by GitHub
parent 9edb2459fd
commit b1af08fed0
10 changed files with 14 additions and 14 deletions
+22
View File
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef EXECUTABLE_SEMANTICS_COMMON_NONNULL_H_
#define EXECUTABLE_SEMANTICS_COMMON_NONNULL_H_
#include <type_traits>
namespace Carbon {
// A non-nullable pointer. Written as `Nonnull<T*>` instead of `T*`.
//
// Sanitizers enforce this dynamically on assignment, return, and when passing
// as an argument. Static analysis will also track erroneous uses of `nullptr`.
template <typename T,
typename std::enable_if_t<std::is_pointer_v<T>>* = nullptr>
using Nonnull = T _Nonnull;
} // namespace Carbon
#endif // EXECUTABLE_SEMANTICS_COMMON_NONNULL_H_