fork(1) download
  1. #include <cstdio>
  2.  
  3. template<class T0> struct prop {
  4.  
  5. T0 operator()() {
  6. return data;
  7. }
  8.  
  9. void operator()( T0 data_ ) {
  10. data = static_cast<T0&&>( data_ ); //data_ is always a copy, so move it
  11. }
  12.  
  13. T0 data;
  14. };
  15.  
  16. struct test {
  17. prop<int> data;
  18. };
  19.  
  20. int main() {
  21.  
  22. test t0{};
  23.  
  24. t0.data( 10 );
  25.  
  26. printf( "data = %d\n", t0.data() );
  27.  
  28. }
  29.  
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
data = 10