fork(1) download
  1. #include <vector>
  2. #include <map>
  3.  
  4. class A {};
  5.  
  6. template<typename T>
  7. class MyAlloc {
  8. public:
  9. MyAlloc(A *) {}
  10. };
  11.  
  12. int main()
  13. {
  14. A *a = new A();
  15. std::vector<int,MyAlloc<int> > v((MyAlloc<int>(a)));
  16.  
  17. /*std::map<std::string, std::string, std::less<std::string>,
  18.   MyAlloc<std::pair<const std::string,std::string> > >
  19.   x ((MyAlloc<std::pair<const std::string, std::string>(a)));*/
  20.  
  21. (void) v.size();
  22. // x.insert(std::make_pair("key","value"));
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.8/bits/stl_construct.h:61:0,
                 from /usr/include/c++/4.8/vector:62,
                 from prog.cpp:1:
/usr/include/c++/4.8/ext/alloc_traits.h: In instantiation of ‘struct __gnu_cxx::__alloc_traits<MyAlloc<int> >’:
/usr/include/c++/4.8/bits/stl_vector.h:75:28:   required from ‘struct std::_Vector_base<int, MyAlloc<int> >’
/usr/include/c++/4.8/bits/stl_vector.h:210:11:   required from ‘class std::vector<int, MyAlloc<int> >’
prog.cpp:15:37:   required from here
/usr/include/c++/4.8/ext/alloc_traits.h:199:53: error: no type named ‘pointer’ in ‘class MyAlloc<int>’
     typedef typename _Alloc::pointer                pointer;
                                                     ^
/usr/include/c++/4.8/ext/alloc_traits.h:200:53: error: no type named ‘const_pointer’ in ‘class MyAlloc<int>’
     typedef typename _Alloc::const_pointer          const_pointer;
                                                     ^
/usr/include/c++/4.8/ext/alloc_traits.h:201:53: error: no type named ‘value_type’ in ‘class MyAlloc<int>’
     typedef typename _Alloc::value_type             value_type;
                                                     ^
/usr/include/c++/4.8/ext/alloc_traits.h:202:53: error: no type named ‘reference’ in ‘class MyAlloc<int>’
     typedef typename _Alloc::reference              reference;
                                                     ^
/usr/include/c++/4.8/ext/alloc_traits.h:203:53: error: no type named ‘const_reference’ in ‘class MyAlloc<int>’
     typedef typename _Alloc::const_reference        const_reference;
                                                     ^
/usr/include/c++/4.8/ext/alloc_traits.h:204:53: error: no type named ‘size_type’ in ‘class MyAlloc<int>’
     typedef typename _Alloc::size_type              size_type;
                                                     ^
/usr/include/c++/4.8/ext/alloc_traits.h:205:53: error: no type named ‘difference_type’ in ‘class MyAlloc<int>’
     typedef typename _Alloc::difference_type        difference_type;
                                                     ^
/usr/include/c++/4.8/ext/alloc_traits.h: In instantiation of ‘struct __gnu_cxx::__alloc_traits<MyAlloc<int> >::rebind<int>’:
/usr/include/c++/4.8/bits/stl_vector.h:75:28:   required from ‘struct std::_Vector_base<int, MyAlloc<int> >’
/usr/include/c++/4.8/bits/stl_vector.h:210:11:   required from ‘class std::vector<int, MyAlloc<int> >’
prog.cpp:15:37:   required from here
/usr/include/c++/4.8/ext/alloc_traits.h:235:62: error: no class template named ‘rebind’ in ‘class MyAlloc<int>’
       { typedef typename _Alloc::template rebind<_Tp>::other other; };
                                                              ^
In file included from /usr/include/c++/4.8/vector:64:0,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_vector.h: In instantiation of ‘class std::vector<int, MyAlloc<int> >’:
prog.cpp:15:37:   required from here
/usr/include/c++/4.8/bits/stl_vector.h:213:58: error: no type named ‘value_type’ in ‘class MyAlloc<int>’
       typedef typename _Alloc::value_type                _Alloc_value_type;
                                                          ^
/usr/include/c++/4.8/bits/stl_vector.h:237:20: error: no members matching ‘std::vector<int, MyAlloc<int> >::_Base {aka std::_Vector_base<int, MyAlloc<int> >}::_M_allocate’ in ‘std::vector<int, MyAlloc<int> >::_Base {aka struct std::_Vector_base<int, MyAlloc<int> >}’
       using _Base::_M_allocate;
                    ^
/usr/include/c++/4.8/bits/stl_vector.h:238:20: error: no members matching ‘std::vector<int, MyAlloc<int> >::_Base {aka std::_Vector_base<int, MyAlloc<int> >}::_M_deallocate’ in ‘std::vector<int, MyAlloc<int> >::_Base {aka struct std::_Vector_base<int, MyAlloc<int> >}’
       using _Base::_M_deallocate;
                    ^
/usr/include/c++/4.8/bits/stl_vector.h:240:20: error: no members matching ‘std::vector<int, MyAlloc<int> >::_Base {aka std::_Vector_base<int, MyAlloc<int> >}::_M_get_Tp_allocator’ in ‘std::vector<int, MyAlloc<int> >::_Base {aka struct std::_Vector_base<int, MyAlloc<int> >}’
       using _Base::_M_get_Tp_allocator;
                    ^
/usr/include/c++/4.8/bits/stl_vector.h: In instantiation of ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = int; _Alloc = MyAlloc<int>]’:
prog.cpp:15:55:   required from here
/usr/include/c++/4.8/bits/stl_vector.h:416:30: error: ‘struct std::_Vector_base<int, MyAlloc<int> >::_Vector_impl’ has no member named ‘_M_start’
         _M_get_Tp_allocator()); }
                              ^
/usr/include/c++/4.8/bits/stl_vector.h:416:30: error: ‘struct std::_Vector_base<int, MyAlloc<int> >::_Vector_impl’ has no member named ‘_M_finish’
/usr/include/c++/4.8/bits/stl_vector.h:416:29: error: ‘_M_get_Tp_allocator’ was not declared in this scope
         _M_get_Tp_allocator()); }
                             ^
/usr/include/c++/4.8/bits/stl_vector.h: In instantiation of ‘std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = MyAlloc<int>; std::vector<_Tp, _Alloc>::size_type = unsigned int]’:
prog.cpp:21:19:   required from here
/usr/include/c++/4.8/bits/stl_vector.h:646:50: error: ‘const struct std::_Vector_base<int, MyAlloc<int> >::_Vector_impl’ has no member named ‘_M_start’
       { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
                                                  ^
/usr/include/c++/4.8/bits/stl_vector.h:646:50: error: ‘const struct std::_Vector_base<int, MyAlloc<int> >::_Vector_impl’ has no member named ‘_M_finish’
/usr/include/c++/4.8/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::_Vector_base(const allocator_type&) [with _Tp = int; _Alloc = MyAlloc<int>; std::_Vector_base<_Tp, _Alloc>::allocator_type = MyAlloc<int>]’:
/usr/include/c++/4.8/bits/stl_vector.h:257:18:   required from ‘std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = MyAlloc<int>; std::vector<_Tp, _Alloc>::allocator_type = MyAlloc<int>]’
prog.cpp:15:55:   required from here
/usr/include/c++/4.8/bits/stl_vector.h:128:20: error: no matching function for call to ‘std::_Vector_base<int, MyAlloc<int> >::_Vector_impl::_Vector_impl(const allocator_type&)’
       : _M_impl(__a) { }
                    ^
/usr/include/c++/4.8/bits/stl_vector.h:128:20: note: candidates are:
/usr/include/c++/4.8/bits/stl_vector.h:86:2: note: std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = int; _Alloc = MyAlloc<int>]
  _Vector_impl()
  ^
/usr/include/c++/4.8/bits/stl_vector.h:86:2: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/4.8/bits/stl_vector.h:79:14: note: std::_Vector_base<int, MyAlloc<int> >::_Vector_impl::_Vector_impl(const std::_Vector_base<int, MyAlloc<int> >::_Vector_impl&)
       struct _Vector_impl 
              ^
/usr/include/c++/4.8/bits/stl_vector.h:79:14: note:   no known conversion for argument 1 from ‘const allocator_type {aka const MyAlloc<int>}’ to ‘const std::_Vector_base<int, MyAlloc<int> >::_Vector_impl&’
/usr/include/c++/4.8/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = int; _Alloc = MyAlloc<int>]’:
/usr/include/c++/4.8/bits/stl_vector.h:257:18:   required from ‘std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = MyAlloc<int>; std::vector<_Tp, _Alloc>::allocator_type = MyAlloc<int>]’
prog.cpp:15:55:   required from here
/usr/include/c++/4.8/bits/stl_vector.h:161:33: error: ‘struct std::_Vector_base<int, MyAlloc<int> >::_Vector_impl’ has no member named ‘_M_start’
         - this->_M_impl._M_start); }
                                 ^
/usr/include/c++/4.8/bits/stl_vector.h:161:9: error: ‘struct std::_Vector_base<int, MyAlloc<int> >::_Vector_impl’ has no member named ‘_M_start’
         - this->_M_impl._M_start); }
         ^
/usr/include/c++/4.8/bits/stl_vector.h:161:9: error: ‘struct std::_Vector_base<int, MyAlloc<int> >::_Vector_impl’ has no member named ‘_M_end_of_storage’
/usr/include/c++/4.8/bits/stl_vector.h:161:33: error: ‘_M_deallocate’ was not declared in this scope
         - this->_M_impl._M_start); }
                                 ^
stdout
Standard output is empty