fork download
  1. template<typename Next>
  2. struct interface_add_sorted_insert : public Next {
  3. void insert(typename Next::value_type const& value) {
  4. typename Next::iterator pos = std::lower_bound(get_impl().begin(), get_impl().end(), value);
  5. get_impl().insert(pos, value);
  6. }
  7. };
  8.  
  9. template<typename Next>
  10. struct interface_add_iterators : public Next {
  11. typename Next::iterator begin() {
  12. return get_impl().begin();
  13. }
  14.  
  15. typename Next::const_iterator begin() const {
  16. return get_impl().begin();
  17. }
  18.  
  19. typename Next::reverse_iterator rbegin() {
  20. return get_impl().rbegin();
  21. }
  22.  
  23. typename Next::const_reverse_iterator rbegin() const {
  24. return get_impl().rbegin();
  25. }
  26.  
  27. typename Next::iterator end() {
  28. return get_impl().end();
  29. }
  30.  
  31. typename Next::const_iterator end() const {
  32. return get_impl().end();
  33. }
  34.  
  35. typename Next::iterator rend() {
  36. return get_impl().rend();
  37. }
  38.  
  39. typename Next::const_reverse_iterator rend() const {
  40. return get_impl().rend();
  41. }
  42. };
  43.  
  44. template<typename Next>
  45. struct interface_add_const_iterators : public Next {
  46. typename Next::const_iterator begin() const {
  47. return get_impl().begin();
  48. }
  49.  
  50. typename Next::const_reverse_iterator rbegin() const {
  51. return get_impl().rbegin();
  52. }
  53.  
  54. typename Next::const_iterator end() const {
  55. return get_impl().end();
  56. }
  57.  
  58. typename Next::const_reverse_iterator rend() const {
  59. return get_impl().rend();
  60. }
  61. };
  62.  
  63. template<typename Next>
  64. struct interface_add_const_metafuncs : public Next {
  65. typename Next::size_type size() const {
  66. return get_impl().size();
  67. }
  68. typename Next::size_type capacity() const {
  69. return get_impl().capacity();
  70. }
  71. typename Next::size_type length() const {
  72. return get_impl().length();
  73. }
  74. bool empty() const {
  75. return get_impl().empty();
  76. }
  77. };
  78.  
  79. template<typename Next>
  80. struct interface_add_back_front : public Next {
  81. typename Next::value_type& front() {
  82. return get_impl().front();
  83. }
  84.  
  85. typename Next::value_type const& front() const {
  86. return get_impl().front();
  87. }
  88.  
  89. typename Next::value_type& back() {
  90. return get_impl().back();
  91. }
  92.  
  93. typename Next::value_type const& back() const {
  94. return get_impl().back();
  95. }
  96. };
  97.  
  98. template<typename Next>
  99. struct interface_add_const_back_front : public Next {
  100. typename Next::value_type const& front() const {
  101. return get_impl().front();
  102. }
  103.  
  104. typename Next::value_type const& back() const {
  105. return get_impl().back();
  106. }
  107. };
  108.  
  109. template<typename Next>
  110. struct interface_add_random_access : public Next {
  111. typename Next::value_type& operator[](typename Next::size_type index) {
  112. return get_impl()[index];
  113. }
  114.  
  115. typename Next::value_type const& operator[](typename Next::size_type index) const {
  116. return get_impl()[index];
  117. }
  118. };
  119.  
  120. template<typename Next>
  121. struct interface_add_const_random_access : public Next {
  122. typename Next::value_type const& operator[](typename Next::size_type index) const {
  123. return get_impl()[index];
  124. }
  125. };
  126.  
  127. template<typename Next>
  128. struct interface_add_sequence_access :
  129. public interface_add_iterators<
  130. interface_add_back_front<
  131. interface_add_random_access<
  132. Next
  133. >
  134. >
  135. > {
  136. };
  137.  
  138. template<typename Next>
  139. struct interface_add_const_sequence_access :
  140. public interface_add_const_iterators<
  141. interface_add_const_back_front<
  142. interface_add_const_random_access<
  143. Next
  144. >
  145. >
  146. > {
  147. };
  148.  
  149. template<typename Impl>
  150. class interface_base {
  151. public:
  152. typedef typename Impl::value_type value_type;
  153. typedef typename Impl::reference reference;
  154. typedef typename Impl::const_reference const_reference;
  155. typedef typename Impl::pointer pointer;
  156. typedef typename Impl::const_pointer const_pointer;
  157. typedef typename Impl::iterator iterator;
  158. typedef typename Impl::const_iterator const_iterator;
  159. typedef typename Impl::reverse_iterator reverse_iterator;
  160. typedef typename Impl::const_reverse_iterator const_reverse_iterator;
  161. typedef typename Impl::size_type size_type;
  162. typedef typename Impl::difference_type difference_type;
  163. typedef typename Impl::allocator_type allocator_type;
  164. typedef Impl container_type;
  165.  
  166. private:
  167. Impl impl;
  168.  
  169. protected:
  170. Impl& get_impl() {
  171. return impl;
  172. }
  173.  
  174. Impl const& get_impl() const {
  175. return impl;
  176. }
  177.  
  178. public:
  179. interface_base()
  180. : impl() {
  181. }
  182.  
  183. explicit interface_base(allocator_type const& allocator)
  184. : impl(allocator) {
  185. }
  186.  
  187. explicit interface_base(size_type n)
  188. : impl(n) {
  189. }
  190.  
  191. interface_base(size_type n, value_type const& value)
  192. : impl(n, value) {
  193. }
  194.  
  195. interface_base(size_type n, value_type const& value, allocator_type const& allocator)
  196. : impl(n, value, allocator) {
  197. }
  198.  
  199. interface_base(container_type const& other)
  200. : impl(other) {
  201. }
  202.  
  203. interface_base(interface_base const& other)
  204. : impl(other.impl) {
  205. }
  206.  
  207. template<typename InputIter>
  208. interface_base(InputIter first, InputIter last)
  209. : impl(first, last) {
  210. }
  211.  
  212. template<typename InputIter>
  213. interface_base(InputIter first, InputIter last, allocator_type const& allocator)
  214. : impl(first, last, allocator) {
  215. }
  216. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void interface_add_sorted_insert<Next>::insert(const typename Next::value_type&)’:
prog.cpp:4:33: error: ‘lower_bound’ is not a member of ‘std’
prog.cpp:4:59: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp:4:59: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
prog.cpp:4:79: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp:5:12: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::iterator interface_add_iterators<Next>::begin()’:
prog.cpp:12:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::const_iterator interface_add_iterators<Next>::begin() const’:
prog.cpp:16:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::reverse_iterator interface_add_iterators<Next>::rbegin()’:
prog.cpp:20:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::const_reverse_iterator interface_add_iterators<Next>::rbegin() const’:
prog.cpp:24:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::iterator interface_add_iterators<Next>::end()’:
prog.cpp:28:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::const_iterator interface_add_iterators<Next>::end() const’:
prog.cpp:32:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::iterator interface_add_iterators<Next>::rend()’:
prog.cpp:36:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::const_reverse_iterator interface_add_iterators<Next>::rend() const’:
prog.cpp:40:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::const_iterator interface_add_const_iterators<Next>::begin() const’:
prog.cpp:47:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::const_reverse_iterator interface_add_const_iterators<Next>::rbegin() const’:
prog.cpp:51:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::const_iterator interface_add_const_iterators<Next>::end() const’:
prog.cpp:55:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::const_reverse_iterator interface_add_const_iterators<Next>::rend() const’:
prog.cpp:59:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::size_type interface_add_const_metafuncs<Next>::size() const’:
prog.cpp:66:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::size_type interface_add_const_metafuncs<Next>::capacity() const’:
prog.cpp:69:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::size_type interface_add_const_metafuncs<Next>::length() const’:
prog.cpp:72:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘bool interface_add_const_metafuncs<Next>::empty() const’:
prog.cpp:75:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::value_type& interface_add_back_front<Next>::front()’:
prog.cpp:82:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘const typename Next::value_type& interface_add_back_front<Next>::front() const’:
prog.cpp:86:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::value_type& interface_add_back_front<Next>::back()’:
prog.cpp:90:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘const typename Next::value_type& interface_add_back_front<Next>::back() const’:
prog.cpp:94:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘const typename Next::value_type& interface_add_const_back_front<Next>::front() const’:
prog.cpp:101:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘const typename Next::value_type& interface_add_const_back_front<Next>::back() const’:
prog.cpp:105:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘typename Next::value_type& interface_add_random_access<Next>::operator[](typename Next::size_type)’:
prog.cpp:112:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘const typename Next::value_type& interface_add_random_access<Next>::operator[](typename Next::size_type) const’:
prog.cpp:116:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
prog.cpp: In member function ‘const typename Next::value_type& interface_add_const_random_access<Next>::operator[](typename Next::size_type) const’:
prog.cpp:123:19: error: there are no arguments to ‘get_impl’ that depend on a template parameter, so a declaration of ‘get_impl’ must be available [-fpermissive]
stdout
Standard output is empty