mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 13:40:12 +01:00
The advantage is a C++ pointer is special, and this approach eliminates the Ptr class type that was causing problems in conversions. Attribute suggestion was courtesy of chandlerc. We're sticking with the Ptr name because it's shorter than Nonnull, and we're likely to keep this in lots of places.
17 lines
507 B
C++
17 lines
507 B
C++
// 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_PTR_H_
|
|
#define EXECUTABLE_SEMANTICS_COMMON_PTR_H_
|
|
|
|
namespace Carbon {
|
|
|
|
// A non-nullable pointer. Written as `Ptr<T>` instead of `T*`.
|
|
template <typename T>
|
|
using Ptr = T* _Nonnull __attribute__((nonnull));
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // EXECUTABLE_SEMANTICS_COMMON_PTR_H_
|