blob: 8e55516b3534cdec9c6d20f669c11fffd57dd999 [file]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_LIB_LOCKDEP_INCLUDE_LOCKDEP_GLOBAL_REFERENCE_H_
#define SRC_LIB_LOCKDEP_INCLUDE_LOCKDEP_GLOBAL_REFERENCE_H_
namespace lockdep {
// Utility type to capture a reference to a global variable in the type system.
// This type can capture an lvalue reference to an object with static storage
// duration, either external or internal linkage.
template <typename T, T& Reference>
struct GlobalReference {};
// Utility type that returns the value type of a GlobalReference and passes
// other types through unchanged.
template <typename T>
struct RemoveGlobalReferenceType {
using Type = T;
};
template <typename T, T& Reference>
struct RemoveGlobalReferenceType<GlobalReference<T, Reference>> {
using Type = T;
};
// Alias to simplify type expressions for RemoveGlobalReferenceType.
template <typename T>
using RemoveGlobalReference = typename RemoveGlobalReferenceType<T>::Type;
} // namespace lockdep
#endif // SRC_LIB_LOCKDEP_INCLUDE_LOCKDEP_GLOBAL_REFERENCE_H_