• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_UNIQUE_PTR_IMPL_REF_TRAITS_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_UNIQUE_PTR_IMPL_REF_TRAITS_H_
7 
8 namespace mojo {
9 
10 // Traits for a binding's implementation reference type.
11 // This corresponds to a unique_ptr reference type.
12 template <typename Interface, typename Deleter = std::default_delete<Interface>>
13 struct UniquePtrImplRefTraits {
14   using PointerType = std::unique_ptr<Interface, Deleter>;
15 
IsNullUniquePtrImplRefTraits16   static bool IsNull(const PointerType& ptr) { return !ptr; }
GetRawPointerUniquePtrImplRefTraits17   static Interface* GetRawPointer(PointerType* ptr) { return ptr->get(); }
18 };
19 
20 }  // namespace mojo
21 
22 #endif  // MOJO_PUBLIC_CPP_BINDINGS_UNIQUE_PTR_IMPL_REF_TRAITS_H_
23