docs
Docs
C++ API
C API
Search API
Ctrl K
2.0
2.0
latest
1.4
Ultralight C++ API
2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Holders.h
Go to the documentation of this file.
1
///
2
/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3
/// A license is required for commercial use. https://ultralig.ht
4
///
5
#pragma once
6
#include <
Ultralight/HolderTraits.h
>
7
8
#include <memory>
9
#include <type_traits>
10
11
namespace
ultralight
{
12
namespace
dom
{
13
14
///
15
/// Whether or not the DOM API can hold an object through H (ignoring const and references), ie.
16
/// ultralight::HolderTraits is specialized for it.
17
///
18
/// Some DOM calls can take a smart pointer to your object instead of a reference. These are the
19
/// listener overloads that take an object and a member function (eg,
20
/// Element::addEventListener() and Element::On()) and the data-binding API
21
/// (ultralight::dom::data):
22
///
23
/// ```
24
/// auto player = std::make_shared<Player>();
25
/// button.addEventListener("click", std::weak_ptr(player), &Player::OnClick);
26
/// ```
27
///
28
/// RefPtr, WeakPtr, std::shared_ptr, std::weak_ptr, and std::unique_ptr work without any setup:
29
///
30
/// - **An owning pointer keeps your object alive** (RefPtr, std::shared_ptr, or a
31
/// std::unique_ptr you move in) for as long as the listener (or binding) exists.
32
/// - **A weak pointer doesn't keep it alive** (WeakPtr or std::weak_ptr). The library locks it
33
/// for each call and skips each call that comes after your object is destroyed. A data
34
/// binding then keeps the values it last published.
35
///
36
/// To use your engine's own smart pointer, specialize ultralight::HolderTraits for it (see
37
/// `<Ultralight/HolderTraits.h>`).
38
///
39
template
<
typename
H>
40
concept
LockableHolder
41
=
requires
{
typename
HolderTraits<std::remove_cvref_t<H>
>::element_type; }
42
&& (ultralight::detail::HolderHasLock<std::remove_cvref_t<H>>
43
|| ultralight::detail::HolderHasGet<std::remove_cvref_t<H>>);
44
45
}
// namespace dom
46
}
// namespace ultralight
HolderTraits.h
ultralight::dom::LockableHolder
Whether or not the DOM API can hold an object through H (ignoring const and references),...
Definition
Holders.h:41
ultralight::dom
Direct C++ access to modify page elements and handle events.
ultralight
Root namespace for every public Ultralight type, function, and enumeration.
ultralight::HolderTraits
Traits template that lets the library hold objects through custom smart pointers.
Definition
HolderTraits.h:156
Ultralight
dom
Holders.h
Docs
C++ API
C API
Version
2.0
2.0
latest
1.4