MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
DynamicPointerCast.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
2// SPDX-License-Identifier: Apache-2.0
3#pragma once
4
5#include <memory>
6
7namespace mxl::lib
8{
9 template<typename To, typename From>
10 std::unique_ptr<To> dynamic_pointer_cast(std::unique_ptr<From>&& source) noexcept
11 {
12 auto const p = dynamic_cast<To*>(source.get());
13 if (p != nullptr)
14 {
15 source.release();
16 }
17 return std::unique_ptr<To>{p};
18 }
19}
std::unique_ptr< To > dynamic_pointer_cast(std::unique_ptr< From > &&source) noexcept