mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:20:10 +01:00
Instead of building the definition of a thunk immediately when we generate the thunk declaration, wait until we reach the `}` of the outermost class, interface, etc. -- at the same time when we would parse the definition of the thunk if it were defined inline. This fixes issues where we fail to define the thunk because it requires an enclosing class to be complete, or its definition depends on something declared later in the enclosing class. Make the representation of a suspended function scope, and its constituent suspended components, be move-only, and switch to passing it around by rvalue reference instead of by value because it's expensive both to move and especially to copy. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
29 lines
1.0 KiB
C++
29 lines
1.0 KiB
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 CARBON_COMMON_MOVE_ONLY_H_
|
|
#define CARBON_COMMON_MOVE_ONLY_H_
|
|
|
|
namespace Carbon {
|
|
|
|
// A base class that indicates a type is move-only. Typically this can be
|
|
// achieved by declaring the move constructor and move assignment yourself; this
|
|
// type should be used only when doing that is not feasible, such as when
|
|
// aggregate initialization is still desired.
|
|
//
|
|
// This class uses CRTP to ensure that each MoveOnly base class has a different
|
|
// type. This is important to avoid the compiler adding extra padding to derived
|
|
// classes to give multiple MoveOnly subobjects of the same type different
|
|
// addresses.
|
|
template <typename Derived>
|
|
struct MoveOnly {
|
|
MoveOnly() = default;
|
|
MoveOnly(MoveOnly&&) noexcept = default;
|
|
auto operator=(MoveOnly&&) noexcept -> MoveOnly& = default;
|
|
};
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // CARBON_COMMON_MOVE_ONLY_H_
|