Skip to content

Commit

Permalink
[共通] ConstantBuffer 改善 #1155
Browse files Browse the repository at this point in the history
  • Loading branch information
Reputeless committed Nov 27, 2023
1 parent ad36bcd commit cf55601
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Siv3D/include/Siv3D/ConstantBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ namespace s3d
SIV3D_NODISCARD_CXX20
ConstantBufferBase() = default;

SIV3D_NODISCARD_CXX20
ConstantBufferBase(const ConstantBufferBase&) = default;

SIV3D_NODISCARD_CXX20
explicit ConstantBufferBase(size_t size);

Expand Down Expand Up @@ -77,6 +74,10 @@ namespace s3d
SIV3D_NODISCARD_CXX20
ConstantBuffer(const Type& data);

template <class ...Args, std::enable_if_t<std::is_constructible_v<Type, Args...>>* = nullptr>
SIV3D_NODISCARD_CXX20
explicit ConstantBuffer(Args&&... args);

ConstantBuffer& operator =(const Type& data);

[[nodiscard]]
Expand Down
8 changes: 8 additions & 0 deletions Siv3D/include/Siv3D/detail/ConstantBuffer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ namespace s3d
m_wrapper->data = data;
}

template <class Type>
template <class ...Args, std::enable_if_t<std::is_constructible_v<Type, Args...>>*>
inline ConstantBuffer<Type>::ConstantBuffer(Args&&... args)
: ConstantBuffer{}
{
m_wrapper->data = Type{ std::forward<Args>(args)... };
}

template <class Type>
inline ConstantBuffer<Type>& ConstantBuffer<Type>::operator =(const Type& data)
{
Expand Down

0 comments on commit cf55601

Please sign in to comment.