fork(4) download
  1. #include <utility>
  2.  
  3. template<class T>
  4. struct movable {
  5. movable() noexcept = default;
  6. ~movable() noexcept { (void) sizeof(T); }
  7. movable(const movable&) noexcept = delete;
  8. movable(movable &&) noexcept = default;
  9. };
  10.  
  11. template<class T>
  12. class wrapper {
  13. public:
  14. movable<T> m;
  15. wrapper() noexcept = default;
  16. wrapper(wrapper &&) noexcept = default;
  17. ~wrapper();
  18. };
  19.  
  20. struct incomplete;
  21.  
  22. int main() {
  23. wrapper<incomplete> original;
  24. wrapper<incomplete> copy(std::move(original));
  25. }
  26.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'movable<T>::~movable() [with T = incomplete]':
prog.cpp:15:5:   required from here
prog.cpp:6:40: error: invalid application of 'sizeof' to incomplete type 'incomplete'
     ~movable() noexcept { (void) sizeof(T); }
                                        ^
stdout
Standard output is empty