fork download
  1. #include <map>
  2. #include <iostream>
  3.  
  4. struct no_copy_type {
  5. double d;
  6. no_copy_type(no_copy_type const&)=delete;
  7. no_copy_type(double x):d(x) {}
  8. ~no_copy_type() { std::cout << "destroyed " << d << "\n"; }
  9. };
  10. int main() {
  11. std::map< int, no_copy_type > m;
  12. m.emplace( std::piecewise_construct,
  13. std::forward_as_tuple(1),
  14. std::forward_as_tuple(3.14)
  15. );
  16. std::cout << "destroy happens next:\n";
  17. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
destroy happens next:
destroyed 3.14