1 // { dg-do run { target c++17 } }
3 #include <experimental/synchronized_value>
4 #include <testsuite_hooks.h>
7 using std::experimental::synchronized_value
;
9 synchronized_value
<std::string
> s
;
11 std::string
read_value(){
12 return apply([](auto& x
){return x
;},s
);
15 void set_value(std::string
const& new_val
){
16 apply([&](auto& x
){ x
= new_val
; }, s
);
22 set_value("new value");
23 VERIFY( read_value() == "new value" );
29 synchronized_value
<int> a(1), b(2), c(3);
30 int sum
= apply([](auto&... ints
) { return (ints
++ + ...); }, a
, b
, c
);
32 auto get
= [](int& i
) { return i
; };
33 VERIFY( apply(get
, a
) == 2 );
34 VERIFY( apply(get
, b
) == 3 );
35 VERIFY( apply(get
, c
) == 4 );