fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. namespace hikky {
  6.  
  7. template<class Type, class Del = default_delete<Type> >
  8. class unique_ptr {
  9.  
  10. public:
  11. typedef Type element_type;
  12. typedef Del deleter_type;
  13. typedef Type pointer;
  14.  
  15. unique_ptr ();
  16. unique_ptr (
  17. nullptr_t _Nptr
  18. );
  19. explicit unique_ptr (
  20. pointer _Ptr
  21. );
  22. unique_ptr (
  23. pointer _Ptr,
  24. typename conditional<
  25. is_reference<Del>::value,
  26. Del,
  27. typename add_reference<const Del>::type
  28. >::type _Deleter
  29. );
  30. unique_ptr (
  31. pointer _Ptr,
  32. typename remove_reference<Del>::type&& _Deleter
  33. );
  34. unique_ptr (
  35. unique_ptr && _Right
  36. );
  37. template<class Type2, class Del2>
  38. unique_ptr (
  39. unique_ptr<Type2, Del2> && _Right
  40. );
  41.  
  42. ~unique_ptr ();
  43.  
  44. unique_ptr& operator= (
  45. unique_ptr && _Right
  46. );
  47. template<class Type2, class Del2>
  48. unique_ptr& operator= (
  49. unique_ptr<Type2, Del2> && _Right
  50. );
  51. void swap (
  52. unique_ptr& _Right
  53. );
  54. pointer release ();
  55. void reset (
  56. pointer _Ptr = pointer()
  57. );
  58.  
  59. pointer get () const;
  60. Type& operator* () const;
  61. pointer operator-> () const;
  62. Del& get_deleter ();
  63. const Del& get_deleter () const;
  64. explicit operator bool () const;
  65.  
  66. unique_ptr(
  67. const unique_ptr& _Right
  68. ) = delete;
  69. unique_ptr& operator=(
  70. const unique_ptr& _Right
  71. ) = delete;
  72.  
  73. private:
  74. pointer stored_ptr; // exposition only
  75. Del stored_deleter; // exposition only
  76. };
  77. }
  78.  
  79. int main() {
  80. // your code goes here
  81. return 0;
  82. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:28:13: error: template argument 3 is invalid
             >::type _Deleter
             ^
prog.cpp:24:22: error: expected nested-name-specifier
             typename conditional<
                      ^
prog.cpp:28:21: error: expected unqualified-id before ‘_Deleter’
             >::type _Deleter
                     ^
prog.cpp:28:21: error: expected ‘)’ before ‘_Deleter’
prog.cpp:28:16: error: expected ‘;’ at end of member declaration
             >::type _Deleter
                ^
prog.cpp:28:21: error: ‘_Deleter’ does not name a type
             >::type _Deleter
                     ^
stdout
Standard output is empty