Skip to content

Commit

Permalink
chore: replace boost::any with std::any
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 5, 2024
1 parent c5ad74d commit e731ab5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
10 changes: 4 additions & 6 deletions src/accelerator/ogl/image/image_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@

#include <GL/glew.h>

#include <boost/any.hpp>

#include <algorithm>
#include <any>
#include <vector>

namespace caspar { namespace accelerator { namespace ogl {
Expand Down Expand Up @@ -274,7 +272,7 @@ struct image_mixer::impl
item.transform = transform_stack_.back();
item.geometry = frame.geometry();

auto textures_ptr = boost::any_cast<std::shared_ptr<std::vector<future_texture>>>(frame.opaque());
auto textures_ptr = std::any_cast<std::shared_ptr<std::vector<future_texture>>>(frame.opaque());

if (textures_ptr) {
item.textures = *textures_ptr;
Expand Down Expand Up @@ -314,10 +312,10 @@ struct image_mixer::impl
std::move(image_data),
array<int32_t>{},
desc,
[weak_self, desc](std::vector<array<const std::uint8_t>> image_data) -> boost::any {
[weak_self, desc](std::vector<array<const std::uint8_t>> image_data) -> std::any {
auto self = weak_self.lock();
if (!self) {
return boost::any{};
return std::any{};
}
std::vector<future_texture> textures;
for (int n = 0; n < static_cast<int>(desc.planes.size()); ++n) {
Expand Down
32 changes: 16 additions & 16 deletions src/common/array.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <boost/any.hpp>

#include <any>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <vector>

Expand All @@ -28,7 +28,7 @@ class array final
auto storage = std::shared_ptr<void>(std::malloc(size), std::free);
ptr_ = reinterpret_cast<T*>(storage.get());
std::memset(ptr_, 0, size_);
storage_ = std::make_shared<boost::any>(std::move(storage));
storage_ = std::make_shared<std::any>(std::move(storage));
}
}

Expand All @@ -37,14 +37,14 @@ class array final
auto storage = std::make_shared<std::vector<T>>(std::move(other));
ptr_ = storage->data();
size_ = storage->size();
storage_ = std::make_shared<boost::any>(std::move(storage));
storage_ = std::make_shared<std::any>(std::move(storage));
}

template <typename S>
explicit array(T* ptr, std::size_t size, S&& storage)
: ptr_(ptr)
, size_(size)
, storage_(std::make_shared<boost::any>(std::forward<S>(storage)))
, storage_(std::make_shared<std::any>(std::forward<S>(storage)))
{
}

Expand Down Expand Up @@ -80,13 +80,13 @@ class array final
template <typename S>
S* storage() const
{
return boost::any_cast<S>(storage_.get());
return std::any_cast<S>(storage_.get());
}

private:
T* ptr_ = nullptr;
std::size_t size_ = 0;
std::shared_ptr<boost::any> storage_;
T* ptr_ = nullptr;
std::size_t size_ = 0;
std::shared_ptr<std::any> storage_;
};

template <typename T>
Expand All @@ -105,7 +105,7 @@ class array<const T> final
auto storage = std::shared_ptr<void>(std::malloc(size), std::free);
ptr_ = reinterpret_cast<T*>(storage.get());
std::memset(ptr_, 0, size_);
storage_ = std::make_shared<boost::any>(storage);
storage_ = std::make_shared<std::any>(storage);
}
}

Expand All @@ -114,14 +114,14 @@ class array<const T> final
auto storage = std::make_shared<std::vector<T>>(std::move(other));
ptr_ = storage->data();
size_ = storage->size();
storage_ = std::make_shared<boost::any>(std::move(storage));
storage_ = std::make_shared<std::any>(std::move(storage));
}

template <typename S>
explicit array(const T* ptr, std::size_t size, S&& storage)
: ptr_(ptr)
, size_(size)
, storage_(std::make_shared<boost::any>(std::forward<S>(storage)))
, storage_(std::make_shared<std::any>(std::forward<S>(storage)))
{
}

Expand Down Expand Up @@ -160,13 +160,13 @@ class array<const T> final
template <typename S>
S* storage() const
{
return boost::any_cast<S>(storage_.get());
return std::any_cast<S>(storage_.get());
}

private:
const T* ptr_ = nullptr;
std::size_t size_ = 0;
std::shared_ptr<boost::any> storage_;
const T* ptr_ = nullptr;
std::size_t size_ = 0;
std::shared_ptr<std::any> storage_;
};

} // namespace caspar
Expand Down
4 changes: 2 additions & 2 deletions src/core/frame/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct const_frame::impl
array<const std::int32_t> audio_data_;
core::pixel_format_desc desc_ = core::pixel_format_desc(pixel_format::invalid);
frame_geometry geometry_ = frame_geometry::get_default();
boost::any opaque_;
std::any opaque_;

impl(std::vector<array<const std::uint8_t>> image_data,
array<const std::int32_t> audio_data,
Expand Down Expand Up @@ -175,6 +175,6 @@ std::size_t const_frame::width() const { return impl_->widt
std::size_t const_frame::height() const { return impl_->height(); }
std::size_t const_frame::size() const { return impl_->size(); }
const frame_geometry& const_frame::geometry() const { return impl_->geometry_; }
const boost::any& const_frame::opaque() const { return impl_->opaque_; }
const std::any& const_frame::opaque() const { return impl_->opaque_; }
const_frame::operator bool() const { return impl_ != nullptr && impl_->desc_.format != core::pixel_format::invalid; }
}} // namespace caspar::core
7 changes: 3 additions & 4 deletions src/core/frame/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

#include <common/array.h>

#include <boost/any.hpp>

#include <any>
#include <cstddef>
#include <cstdint>
#include <functional>
Expand All @@ -17,7 +16,7 @@ class mutable_frame final
friend class const_frame;

public:
using commit_t = std::function<boost::any(std::vector<array<const std::uint8_t>>)>;
using commit_t = std::function<std::any(std::vector<array<const std::uint8_t>>)>;

explicit mutable_frame(const void* tag,
std::vector<array<std::uint8_t>> image_data,
Expand Down Expand Up @@ -80,7 +79,7 @@ class const_frame final

std::size_t size() const;

const boost::any& opaque() const;
const std::any& opaque() const;

const class frame_geometry& geometry() const;

Expand Down

0 comments on commit e731ab5

Please sign in to comment.