#include <iostream>
#include <bitset>
#include <vector>
template <size_t SIZE>
bool operator > (const std::bitset<SIZE> & bs1, const std::bitset<SIZE> & bs2){
return(bs1.to_ulong() > bs2.to_ulong());
}
template <size_t SIZE>
bool operator >=(const std::bitset<SIZE> & bs1, const std::bitset<SIZE> & bs2){
return(bs1.to_ulong() >= bs2.to_ulong());
}
template <size_t SIZE>
bool operator < (const std::bitset<SIZE> & bs1, const std::bitset<SIZE> & bs2){
return(bs1.to_ulong() < bs2.to_ulong());
}
template <size_t SIZE>
bool operator <=(const std::bitset<SIZE> & bs1, const std::bitset<SIZE> & bs2){
return(bs1.to_ulong() <= bs2.to_ulong());
}
using namespace std;
int main(void){
vector< bitset<5> > x, y;
x.push_back(bitset<5>(0b11011));
x.push_back(bitset<5>(0b00011));
x.push_back(bitset<5>(0b01110));
y.push_back(bitset<5>(0b11001));
y.push_back(bitset<5>(0b11001));
y.push_back(bitset<5>(0b11111));
cout << (x[0] > y[0]) << endl; // ここは普通にOKなんだけど…
cout << (x > y) << endl; // ここが何故かコンパイルエラー
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Yml0c2V0PgojaW5jbHVkZSA8dmVjdG9yPgoKdGVtcGxhdGUgPHNpemVfdCBTSVpFPgpib29sIG9wZXJhdG9yID4gKGNvbnN0IHN0ZDo6Yml0c2V0PFNJWkU+ICYgYnMxLCBjb25zdCBzdGQ6OmJpdHNldDxTSVpFPiAmIGJzMil7CiAgICByZXR1cm4oYnMxLnRvX3Vsb25nKCkgPiBiczIudG9fdWxvbmcoKSk7Cn0KdGVtcGxhdGUgPHNpemVfdCBTSVpFPgpib29sIG9wZXJhdG9yID49KGNvbnN0IHN0ZDo6Yml0c2V0PFNJWkU+ICYgYnMxLCBjb25zdCBzdGQ6OmJpdHNldDxTSVpFPiAmIGJzMil7CiAgICByZXR1cm4oYnMxLnRvX3Vsb25nKCkgPj0gYnMyLnRvX3Vsb25nKCkpOwp9CnRlbXBsYXRlIDxzaXplX3QgU0laRT4KYm9vbCBvcGVyYXRvciA8IChjb25zdCBzdGQ6OmJpdHNldDxTSVpFPiAmIGJzMSwgY29uc3Qgc3RkOjpiaXRzZXQ8U0laRT4gJiBiczIpewogICAgcmV0dXJuKGJzMS50b191bG9uZygpIDwgYnMyLnRvX3Vsb25nKCkpOwp9CnRlbXBsYXRlIDxzaXplX3QgU0laRT4KYm9vbCBvcGVyYXRvciA8PShjb25zdCBzdGQ6OmJpdHNldDxTSVpFPiAmIGJzMSwgY29uc3Qgc3RkOjpiaXRzZXQ8U0laRT4gJiBiczIpewogICAgcmV0dXJuKGJzMS50b191bG9uZygpIDw9IGJzMi50b191bG9uZygpKTsKfQoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4odm9pZCl7CiAgICB2ZWN0b3I8IGJpdHNldDw1PiA+IHgsIHk7CiAgICB4LnB1c2hfYmFjayhiaXRzZXQ8NT4oMGIxMTAxMSkpOwogICAgeC5wdXNoX2JhY2soYml0c2V0PDU+KDBiMDAwMTEpKTsKICAgIHgucHVzaF9iYWNrKGJpdHNldDw1PigwYjAxMTEwKSk7CiAgICAKICAgIHkucHVzaF9iYWNrKGJpdHNldDw1PigwYjExMDAxKSk7CiAgICB5LnB1c2hfYmFjayhiaXRzZXQ8NT4oMGIxMTAwMSkpOwogICAgeS5wdXNoX2JhY2soYml0c2V0PDU+KDBiMTExMTEpKTsKICAgIAogICAgY291dCA8PCAoeFswXSA+IHlbMF0pIDw8IGVuZGw7IC8vIOOBk+OBk+OBr+aZrumAmuOBq09L44Gq44KT44Gg44GR44Gp4oCmCiAgICBjb3V0IDw8ICh4ID4geSkgPDwgZW5kbDsgLy8g44GT44GT44GM5L2V5pWF44GL44Kz44Oz44OR44Kk44Or44Ko44Op44O8Cn0=
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h: In static member function ‘static bool std::__lexicographical_compare<_BoolType>::__lc(_II1, _II1, _II2, _II2) [with _II1 = const std::bitset<5u>*, _II2 = const std::bitset<5u>*, bool _BoolType = false]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:924: instantiated from ‘bool std::__lexicographical_compare_aux(_II1, _II1, _II2, _II2) [with _II1 = const std::bitset<5u>*, _II2 = const std::bitset<5u>*]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:1022: instantiated from ‘bool std::lexicographical_compare(_II1, _II1, _II2, _II2) [with _II1 = __gnu_cxx::__normal_iterator<const std::bitset<5u>*, std::vector<std::bitset<5u>, std::allocator<std::bitset<5u> > > >, _II2 = __gnu_cxx::__normal_iterator<const std::bitset<5u>*, std::vector<std::bitset<5u>, std::allocator<std::bitset<5u> > > >]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_vector.h:1128: instantiated from ‘bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) [with _Tp = std::bitset<5u>, _Alloc = std::allocator<std::bitset<5u> >]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_vector.h:1140: instantiated from ‘bool std::operator>(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) [with _Tp = std::bitset<5u>, _Alloc = std::allocator<std::bitset<5u> >]’
prog.cpp:34: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:885: error: no match for ‘operator<’ in ‘* __first1 < * __first2’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:887: error: no match for ‘operator<’ in ‘* __first2 < * __first1’