fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <cstdint>
  5. #include <random>
  6. #include <limits>
  7. #include <functional>
  8. #include <map>
  9. #include <chrono>
  10. #include <stdexcept>
  11. #include <iterator>
  12. typedef std::vector<std::uint8_t> BType;
  13. typedef std::vector<BType> Block;
  14.  
  15. template<class T>
  16. class GhostMemory{
  17. std::size_t N;
  18. T* P;
  19. public:
  20. GhostMemory(T* Po = nullptr, std::size_t Num = 0) :P(Po), N(Num){}
  21.  
  22. std::size_t Size(){
  23. return N;
  24. }
  25. const T* Pointer(){
  26. return P;
  27. }
  28. T& operator [](const std::size_t Idx){
  29. if (N <= Idx) throw std::out_of_range("OutOfRange in GhostMemory<T>::operator []");
  30. return P[Idx];
  31. }
  32. const T& operator [](const std::size_t Idx)const{
  33. if (N <= Idx) throw std::out_of_range("OutOfRange in GhostMemory<T>::operator []");
  34. return P[Idx];
  35. }
  36. bool operator ==(GhostMemory<T>&In){
  37. if (N != In.N) return false;
  38. for (std::size_t i = 0; i < N; i++){
  39. if ((*this)[i] != In[i]) return false;
  40. }
  41. return true;
  42. }
  43. /**/
  44. bool operator <(GhostMemory<T>&In){
  45. if (N < In.N) return true;
  46. //if (N < In.N) return false;
  47. for (std::size_t i = 0; i < N; i++){
  48. if ((*this)[i] != In[i]){
  49. return (*this)[i]<In[i];
  50. }
  51. }
  52. return false;
  53. }
  54. /**/
  55. bool operator >(GhostMemory<T>&In){
  56. if (N > In.N) return true;
  57. //if (N < In.N) return false;
  58. for (std::size_t i = 0; i < N; i++){
  59. if ((*this)[i] != In[i]){
  60. return (*this)[i]>In[i];
  61. }
  62. }
  63. return false;
  64. }
  65. /**/
  66. };
  67.  
  68. typedef std::vector<GhostMemory<std::uint8_t>> Block2;
  69.  
  70.  
  71. BType MakeData(std::size_t N = std::numeric_limits<std::uint16_t>::max()){
  72.  
  73. std::random_device RD;
  74. std::mt19937 mt(RD());
  75. // std::mt19937 mt(0);
  76. std::uniform_int_distribution<int> uid(0, 255);
  77.  
  78. BType ret;
  79. for (std::size_t i = 0; i < N; i++){
  80. ret.push_back(uid(mt));
  81. }
  82.  
  83. return ret;
  84. }
  85.  
  86. bool Append(Block& B, BType& Data){
  87.  
  88. B.push_back(Data);
  89.  
  90. return true;
  91. }
  92.  
  93. std::pair<std::size_t,BType> BlockSortEn(BType& Data){
  94. auto T = Data;
  95. Block B;
  96. BType R;
  97. std::size_t j = 0;
  98. for (std::size_t i = 0; i < T.size(); i++){
  99. Append(B, T);
  100. std::rotate(T.begin(), T.begin()+1, T.end());
  101.  
  102. }
  103. std::sort(B.begin(), B.end());
  104.  
  105. for (std::size_t i = 0; i < B.size(); i++){
  106. R.push_back(B[i][Data.size() - 1]);
  107. if (B[i] == Data) j = i;
  108. }
  109.  
  110. return std::make_pair(j,R);
  111. }
  112. std::pair<std::size_t,BType> BlockSortEn2(BType& Data){
  113. auto T = Data;
  114. Block2 B;
  115. BType R;
  116. std::size_t j = 0;
  117.  
  118. GhostMemory < std::uint8_t> D;
  119.  
  120. auto bi = std::back_inserter(T);
  121. for (auto o : Data) bi = o;
  122. //bi = '\0';//debug for ascii char data.for debugger.
  123.  
  124. for (std::size_t i = 0; i < Data.size(); i++){
  125. GhostMemory<std::uint8_t> GM(static_cast<std::uint8_t*>(&T[i]), Data.size());
  126. B.push_back(GM);
  127. }
  128. D = B[0];
  129. std::sort(B.begin(), B.end());
  130.  
  131. for (std::size_t i = 0; i < B.size(); i++){
  132. R.push_back(B[i][Data.size() - 1]);
  133. if (B[i].Pointer() == D.Pointer()) j = i;
  134. }
  135.  
  136. return std::make_pair(j,R);
  137. }
  138. BType BlockSortDe(std::pair<std::size_t, BType>& Data){
  139. std::vector<std::pair<std::uint8_t,std::size_t>> T;
  140. BType R;
  141. for (std::size_t i = 0; i < Data.second.size(); i++){
  142. T.push_back(std::make_pair(Data.second[i], i));
  143. }
  144. std::sort(T.begin(), T.end());
  145. std::size_t P = Data.first;
  146. for (std::size_t i = 0; i < T.size(); i++){
  147. R.push_back(T[P].first);
  148. P = T[P].second;
  149. }
  150.  
  151. return R;
  152.  
  153. }
  154.  
  155. bool MakeHoge(BType D){
  156.  
  157. auto Start = std::chrono::high_resolution_clock::now();
  158.  
  159. auto BSE = BlockSortEn2(D);
  160. auto BSD = BlockSortDe(BSE);
  161.  
  162. auto End = std::chrono::high_resolution_clock::now();
  163.  
  164. auto E = std::chrono::duration_cast<std::chrono::milliseconds>(End - Start);
  165.  
  166. std::cout << "経過時間は" << E.count() << "msでした。"<<std::endl;
  167.  
  168. std::cout << "オリジナル" << std::endl;
  169. for (auto& o : D) std::cout << static_cast<int>(o) << ',';
  170. std::cout << std::endl;
  171. std::cout << "復号化" << std::endl;
  172. for (auto& o : BSD) std::cout << static_cast<int>(o) << ',';
  173. std::cout << std::endl;
  174. std::cout << "符号化@" <<BSE.first<< std::endl;
  175. for (auto& o : BSE.second) std::cout << static_cast<int>(o) << ',';
  176. std::cout << std::endl;
  177.  
  178. if (D == BSD){
  179. std::cout << "データ完全一致!" << std::endl;
  180. }
  181. else{
  182. std::cout << "データ完全一致しませんでした!" << std::endl;
  183. }
  184.  
  185. //std::cout << "経過時間は" << E.count() << "msでした。"<<std::endl;
  186.  
  187.  
  188. return true;
  189. }
  190.  
  191. bool GMemTest(){
  192. std::uint8_t S1[] = "1234567";
  193. std::uint8_t S3[] = "2234567";
  194. std::uint8_t S2[] = "123456";
  195. GhostMemory<std::uint8_t> G1(S1, sizeof(S1));
  196. GhostMemory<std::uint8_t> G2(S2, sizeof(S2));
  197. GhostMemory<std::uint8_t> G3(S3, sizeof(S3));
  198.  
  199. std::vector<int> V1{ 1, 2, 3 };
  200. std::vector<int> V2{ 1, 2 };
  201. /**/
  202. if (V1 > V2){
  203. std::cout << "std::vector is Large is Greater"<<std::endl;
  204. }
  205. else{
  206. std::cout << "std::vector is Small is Greater"<<std::endl;
  207. }
  208.  
  209. if (G1 == G1){
  210. std::cout << "GhostMemory::oeprator = is Work;"<<std::endl;
  211. }
  212. else{
  213. std::cout << "GhostMemory::oeprator = is Not Work;"<<std::endl;
  214. }
  215. if (G1 > G1){
  216. std::cout << "GhostMemory::oeprator = is not Work@;"<<std::endl;
  217. }
  218. else{
  219. std::cout << "GhostMemory::oeprator = is Work@;"<<std::endl;
  220. }
  221. if (G1 < G1){
  222. std::cout << "GhostMemory::oeprator = is not Work@;"<<std::endl;
  223. }
  224. else{
  225. std::cout << "GhostMemory::oeprator = is Work@;"<<std::endl;
  226. }
  227. if (G1 > G2){
  228. std::cout << "GhostMemory::oeprator > is Work;"<<std::endl;
  229. }
  230. else{
  231. std::cout << "GhostMemory::oeprator > is Not Work;"<<std::endl;
  232. }
  233. if (G1 < G2){
  234. std::cout << "GhostMemory::oeprator < is not Work;"<<std::endl;
  235. }
  236. else{
  237. std::cout << "GhostMemory::oeprator < is Work;"<<std::endl;
  238. }
  239. if (G1 > G3){
  240. std::cout << "GhostMemory::oeprator > is Not Work@2;"<<std::endl;
  241. }
  242. else{
  243. std::cout << "GhostMemory::oeprator > is Work@2;"<<std::endl;
  244. }
  245. if (G1 < G3){
  246. std::cout << "GhostMemory::oeprator < is Work@2;"<<std::endl;
  247. }
  248. else{
  249. std::cout << "GhostMemory::oeprator < is Not Work@2;"<<std::endl;
  250. }
  251. /**/
  252. return true;
  253. }
  254.  
  255.  
  256. int main(){
  257. static const std::size_t L = 1024*6;
  258. auto D = MakeData(L);
  259. BType A{ 'A', 'B', 'B', 'A', 'C' }; //サンプルA
  260. BType B{ 'a','e','a','d','a','c','a','b' };//サンプルB
  261. /* */
  262. MakeHoge(A);
  263. std::cout << std::endl;
  264. MakeHoge(B);
  265. std::cout << std::endl;
  266. MakeHoge(D);
  267. std::cout << std::endl;
  268.  
  269.  
  270. //GMemTest();
  271.  
  272.  
  273. return 0;
  274. }
  275.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘GhostMemory<T>::GhostMemory(T*, std::size_t) [with T = unsigned char; std::size_t = unsigned int]’:
prog.cpp:118:30:   required from here
prog.cpp:18:5: warning: ‘GhostMemory<unsigned char>::P’ will be initialized after [-Wreorder]
  T* P;
     ^
prog.cpp:17:14: warning:   ‘std::size_t GhostMemory<unsigned char>::N’ [-Wreorder]
  std::size_t N;
              ^
prog.cpp:20:2: warning:   when initialized here [-Wreorder]
  GhostMemory(T* Po = nullptr, std::size_t Num = 0) :P(Po), N(Num){}
  ^
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h: In instantiation of ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<GhostMemory<unsigned char>*, std::vector<GhostMemory<unsigned char> > >; _Tp = GhostMemory<unsigned char>]’:
/usr/include/c++/4.8/bits/stl_algo.h:2307:70:   required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<GhostMemory<unsigned char>*, std::vector<GhostMemory<unsigned char> > >]’
/usr/include/c++/4.8/bits/stl_algo.h:2338:54:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<GhostMemory<unsigned char>*, std::vector<GhostMemory<unsigned char> > >; _Size = int]’
/usr/include/c++/4.8/bits/stl_algo.h:5475:36:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<GhostMemory<unsigned char>*, std::vector<GhostMemory<unsigned char> > >]’
prog.cpp:129:30:   required from here
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: error: no match for ‘operator<’ (operand types are ‘GhostMemory<unsigned char>’ and ‘const GhostMemory<unsigned char>’)
    while (*__first < __pivot)
                    ^
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note: candidates are:
prog.cpp:44:7: note: bool GhostMemory<T>::operator<(GhostMemory<T>&) [with T = unsigned char]
  bool operator <(GhostMemory<T>&In){
       ^
prog.cpp:44:7: note:   no known conversion for argument 1 from ‘const GhostMemory<unsigned char>’ to ‘GhostMemory<unsigned char>&’
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_pair.h:220:5: note: template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
     ^
/usr/include/c++/4.8/bits/stl_pair.h:220:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::pair<_T1, _T2>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:297:5: note: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
     operator<(const reverse_iterator<_Iterator>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:297:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::reverse_iterator<_Iterator>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:347:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
     operator<(const reverse_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:347:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::reverse_iterator<_Iterator>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
     operator<(const move_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::move_iterator<_Iterator>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note: template<class _Iterator> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
     operator<(const move_iterator<_Iterator>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::move_iterator<_Iterator>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/string:52:0,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2569:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/4.8/bits/basic_string.h:2569:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/string:52:0,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2581:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/4.8/bits/basic_string.h:2581:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/string:52:0,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2593:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator<(const _CharT* __lhs,
     ^
/usr/include/c++/4.8/bits/basic_string.h:2593:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   mismatched types ‘const _CharT*’ and ‘GhostMemory<unsigned char>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/vector:64:0,
                 from prog.cpp:2:
/usr/include/c++/4.8/bits/stl_vector.h:1420:5: note: template<class _Tp, class _Alloc> bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
     operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
     ^
/usr/include/c++/4.8/bits/stl_vector.h:1420:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::vector<_Tp, _Alloc>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/tuple:39:0,
                 from /usr/include/c++/4.8/functional:55,
                 from /usr/include/c++/4.8/bits/stl_algo.h:66,
                 from /usr/include/c++/4.8/algorithm:62,
                 from prog.cpp:3:
/usr/include/c++/4.8/array:238:5: note: template<class _Tp, unsigned int _Nm> bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)
     operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
     ^
/usr/include/c++/4.8/array:238:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::array<_Tp, _Nm>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/functional:55:0,
                 from /usr/include/c++/4.8/bits/stl_algo.h:66,
                 from /usr/include/c++/4.8/algorithm:62,
                 from prog.cpp:3:
/usr/include/c++/4.8/tuple:822:5: note: template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const std::tuple<_Elements ...>&, const std::tuple<_Elements ...>&)
     operator<(const tuple<_TElements...>& __t,
     ^
/usr/include/c++/4.8/tuple:822:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::tuple<_Elements ...>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/map:60:0,
                 from prog.cpp:8:
/usr/include/c++/4.8/bits/stl_tree.h:917:5: note: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
     operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
     ^
/usr/include/c++/4.8/bits/stl_tree.h:917:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/map:61:0,
                 from prog.cpp:8:
/usr/include/c++/4.8/bits/stl_map.h:979:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
     operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
     ^
/usr/include/c++/4.8/bits/stl_map.h:979:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::map<_Key, _Tp, _Compare, _Alloc>’
    while (*__first < __pivot)
                    ^
In file included from /usr/include/c++/4.8/map:62:0,
                 from prog.cpp:8:
/usr/include/c++/4.8/bits/stl_multimap.h:881:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
     operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
     ^
/usr/include/c++/4.8/bits/stl_multimap.h:881:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: note:   ‘GhostMemory<unsigned char>’ is not derived from ‘const std::multimap<_Key, _Tp, _Compare, _Alloc>’
    while (*__first < __pivot)
                    ^
/usr/include/c++/4.8/bits/stl_algo.h:2269:19: error: passing ‘const GhostMemory<unsigned char>’ as ‘this’ argument of ‘bool GhostMemory<T>::operator<(GhostMemory<T>&) [with T = unsigned char]’ discards qualifiers [-fpermissive]
    while (__pivot < *__last)
                   ^
stdout
Standard output is empty