Skip to content

Commit

Permalink
Remove the is_constructible check because it breaks the usecase with …
Browse files Browse the repository at this point in the history
…forward declared types
  • Loading branch information
alex-sparus committed Mar 12, 2024
1 parent 9121da5 commit c29e7ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions immer/box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class box
*/
template <typename Arg,
typename Enable = std::enable_if_t<
!std::is_same<box, std::decay_t<Arg>>::value &&
std::is_constructible<T, Arg>::value>>
!std::is_same<box, std::decay_t<Arg>>::value>>
box(Arg&& arg)
: impl_{detail::make<heap, holder>(std::forward<Arg>(arg))}
{}
Expand Down
18 changes: 18 additions & 0 deletions test/extra/archive/test_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,21 @@ TEST_CASE("Test saving and mutating a box")
const auto loaded2 = loader.load(id2);
REQUIRE(loaded2.get() == "hello world");
}

namespace {
struct fwd_type;
struct test_type
{
immer::box<fwd_type> data;
};
struct fwd_type
{
int data = 123;
};
} // namespace

TEST_CASE("Test box with a fwd declared type")
{
auto val = test_type{};
REQUIRE(val.data.get().data == 123);
}

0 comments on commit c29e7ff

Please sign in to comment.