Skip to content

Commit

Permalink
address of Fn::F must be invariant under move ... use std::unique_ptr…
Browse files Browse the repository at this point in the history
… which makes Fn truly move-only. Still fails in last send when trying to copy Fn
  • Loading branch information
evaleev committed Apr 8, 2024
1 parent ee5804f commit 92df972
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/unit/fibonacci_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
const int64_t F_n_max = 1000;
/// N.B. contains values of F_n and F_{n-1}
struct Fn : public ttg::TTValue<Fn> {
int64_t F[2] = {1, 0}; // F[0] = F_n, F[1] = F_{n-1}
std::unique_ptr<int64_t[]> F; // F[0] = F_n, F[1] = F_{n-1}
ttg::Buffer<int64_t> b;

Fn() : b(&F[0], 2) {}
Fn() : F(std::make_unique<int64_t[]>(2)), b(F.get(), 2) { F[0] = 1; F[1] = 0; }

Fn(const Fn&) = delete;
Fn(Fn&& other) = default;
Expand Down Expand Up @@ -57,7 +57,7 @@ auto make_ttg_fib_lt(const int64_t F_n_max = 1000) {
},
ttg::edges(f2f), ttg::edges(f2f, f2p), "fib");
auto print = ttg::make_tt(
[=](Fn f_n) {
[=](Fn&& f_n) {
std::cout << "The largest Fibonacci number smaller than " << F_n_max << " is " << f_n.F[1] << std::endl;
},
ttg::edges(f2p), ttg::edges(), "print");
Expand Down

0 comments on commit 92df972

Please sign in to comment.