fork download
  1. #include <tuple>
  2. #include <memory>
  3.  
  4.  
  5. template<typename T>
  6. struct holder {};
  7.  
  8. struct abstract {
  9.  
  10. virtual ~abstract() = 0;
  11. };
  12.  
  13. abstract::~abstract() {}
  14.  
  15.  
  16. int main() {
  17. using types = std::tuple<abstract>;
  18. using holder_t = holder<types>;
  19.  
  20. // Ok
  21. holder_t local;
  22.  
  23. // Ok
  24. new holder_t;
  25.  
  26. // ?
  27. std::unique_ptr<holder_t> unique(new holder_t);
  28.  
  29. // ?
  30. std::make_shared<holder_t>();
  31. }
  32.  
Compilation error #stdin compilation error #stdout 0s 2980KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:21:13: warning: unused variable ‘local’ [-Wunused-variable]
In file included from prog.cpp:1:0:
/usr/include/c++/4.7/tuple: In instantiation of ‘struct std::_Head_base<0u, abstract, false>’:
/usr/include/c++/4.7/tuple:215:12:   required from ‘struct std::_Tuple_impl<0u, abstract>’
/usr/include/c++/4.7/tuple:374:11:   required from ‘class std::tuple<abstract>’
/usr/include/c++/4.7/tuple:744:35:   required from ‘constexpr typename std::__add_ref<typename std::tuple_element<__i, std::tuple<_Elements ...> >::type>::type std::get(std::tuple<_Elements ...>&) [with unsigned int __i = 0u; _Elements = {holder<std::tuple<abstract> >*, std::default_delete<holder<std::tuple<abstract> > >}; typename std::__add_ref<typename std::tuple_element<__i, std::tuple<_Elements ...> >::type>::type = holder<std::tuple<abstract> >*&]’
/usr/include/c++/4.7/bits/unique_ptr.h:171:32:   required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = holder<std::tuple<abstract> >; _Dp = std::default_delete<holder<std::tuple<abstract> > >]’
prog.cpp:27:49:   required from here
/usr/include/c++/4.7/tuple:166:13: error: cannot declare field ‘std::_Head_base<0u, abstract, false>::_M_head_impl’ to be of abstract type ‘abstract’
prog.cpp:8:8: note:   because the following virtual functions are pure within ‘abstract’:
prog.cpp:13:1: note: 	virtual abstract::~abstract()
stdout
Standard output is empty