22 template <
typename T,
typename... Args>
23 constexpr
auto size(
const T&, Args&&... ) noexcept {
24 static_assert(
sizeof...( Args ) == 0,
"No extra args please" );
31 virtual std::optional<std::size_t>
size()
const = 0;
34 void const* m_ptr =
nullptr;
35 std::type_index m_type =
typeid( void );
39 Ptr( T
const*
t ) : m_ptr{
t }, m_type{
typeid( T ) } {}
41 operator void const*()
const {
return m_ptr; }
42 std::type_index
type()
const {
return m_type; }
45 T
const*
get()
const {
46 if ( std::is_void_v<T> || m_type == std::type_index(
typeid( T ) ) )
return static_cast<T const*
>( m_ptr );
47 struct bad_AnyDataWrapper_Ptr_cast : std::bad_cast {};
48 throw bad_AnyDataWrapper_Ptr_cast{};
66 const T&
getData()
const {
return m_data; }
69 std::optional<std::size_t>
size()
const override {
71 return size( getData() );
77 template <
typename ViewType,
typename OwnedType>