fork download
  1. #include <memory>
  2. #include <vector>
  3.  
  4. int main() {
  5. std::vector<std::unique_ptr<int*>> tablica;
  6. tablica[0] = new int(5);
  7. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:6:27: error: no match for ‘operator=’ in ‘tablica.std::vector<_Tp, _Alloc>::operator[]<std::unique_ptr<int*>, std::allocator<std::unique_ptr<int*> > >(0u) = (operator new(4u), (<statement>, ((int*)<anonymous>)))’
prog.cpp:6:27: note: candidates are:
In file included from /usr/include/c++/4.7/memory:86:0,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/unique_ptr.h:179:7: note: std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = int*; _Dp = std::default_delete<int*>; std::unique_ptr<_Tp, _Dp> = std::unique_ptr<int*>]
/usr/include/c++/4.7/bits/unique_ptr.h:179:7: note:   no known conversion for argument 1 from ‘int*’ to ‘std::unique_ptr<int*>&&’
/usr/include/c++/4.7/bits/unique_ptr.h:192:2: note: template<class _Up, class _Ep, class> std::unique_ptr& std::unique_ptr::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Up = _Up; _Ep = _Ep; <template-parameter-2-3> = <template-parameter-1-3>; _Tp = int*; _Dp = std::default_delete<int*>]
/usr/include/c++/4.7/bits/unique_ptr.h:192:2: note:   template argument deduction/substitution failed:
prog.cpp:6:27: note:   mismatched types ‘std::unique_ptr<_Up, _Ep>’ and ‘int*’
In file included from /usr/include/c++/4.7/memory:86:0,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/unique_ptr.h:200:7: note: std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::nullptr_t) [with _Tp = int*; _Dp = std::default_delete<int*>; std::unique_ptr<_Tp, _Dp> = std::unique_ptr<int*>; std::nullptr_t = std::nullptr_t]
/usr/include/c++/4.7/bits/unique_ptr.h:200:7: note:   no known conversion for argument 1 from ‘int*’ to ‘std::nullptr_t’
stdout
Standard output is empty