1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 namespace lockdep {
8 
9 // Utility type to capture a reference to a global variable in the type system.
10 // This type can capture an lvalue reference to an object with static storage
11 // duration, either external or internal linkage.
12 template <typename T, T& Reference>
13 struct GlobalReference {};
14 
15 // Utility type that returns the value type of a GlobalReference and passes
16 // other types through unchanged.
17 template <typename T>
18 struct RemoveGlobalReferenceType {
19     using Type = T;
20 };
21 template <typename T, T& Reference>
22 struct RemoveGlobalReferenceType<GlobalReference<T, Reference>> {
23     using Type = T;
24 };
25 
26 // Alias to simplify type expressions for RemoveGlobalReferenceType.
27 template <typename T>
28 using RemoveGlobalReference = typename RemoveGlobalReferenceType<T>::Type;
29 
30 } // namespace lockdep
31