わいえむねっと

Contents
Categories
Calendar
2026/08
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Monthly Archives
~2000/01
Recent Entries
RSS1.0
Templates
Information
Processed: 0.088 sec
Chashed: -
2007/04/15 Sun
好きなことしてるんだろ? いくら喰いたい。 ソケット数の制限とか。

Maximum Number of Sockets an Application Can Use
http://support.mi​crosoft.co​m/kb/111855/en-us
The maximum number of sockets that a Windows Sockets application can use is determined at compile time by the manifest constant FD_SETSIZE. To do this, from the Win32 SDK WINSOCK.H file:

This value is used in constructing the fd_set structures used in select(). The default value in WINSOCK.H is 64. If an application is designed to be capable of working with more than 64 sockets, define the manifest FD_SETSIZE in every source file before including WINSOCK.H. One way of doing this is to include the definition within the compiler options in the makefile, such as adding -DFD_SETSIZE=128 as an option to the compiler command line for Microsoft C.

64で足りなければFD_SETSIZEを増やせばいいじゃないと言っているけれど、MAXIMUM_WAIT_OBJECTSに関して同様の情報はなし。

WinNT.h
#define MAXIMUM_WAIT_OBJECTS 64 // Maximum number of wait objects

イベントで処理するためにはスレッドなりなんなりで階層化するしかないのか。
LinuxのFD_SETSIZEは、

sys/select.h
/* Get definition of needed basic types. */
#include <bits/types.h>

#define FD_SETSIZE __FD_SETSIZE

で、

bits/types.h
#include <bits/typesizes.h> /* Defines __*_T_TYPE macros. */

から、

bits/typesizes.h
#define __FD_SETSIZE 1024

と。glibc-2.3.4。
Windowsのデフォルトは小さすぎる。
2007/04/14 Sat
引用行のイタリックが読みにくすぎるのでborder-leftに。
ボックスをoverflow:autoに。
なんだかんだで朝に。 いくら喰いたい。 落ちているうちに配達員がきてた模様。不覚。 いくら喰いたい。
2007/04/13 Fri
2時。
寝ると見せかけてウィスキーをぐいー。 そして昨日と同じ電車でやっぱり豚角煮まんは食う。 航空関係の仕事をいくつかやってきたわけですが、ドキュメントが『かんせいとしょ』と呼ばれていたのは『完成図書』でなくて『管制図書』だったのでは。
とか今更のように気付く。 well-knownじゃないよ、ephemeralだよ。

The default dynamic port range for TCP/IP has changed in Windows Vista Enterprise
http://support.mi​crosoft.co​m/kb/929851/en-us
To conform with IANA port-assignment standards, the default dynamic port range for TCP/IP has changed from 1024-5000 to 49152-65535 in Windows Vista Enterprise.

Widnowsでは1024~5000がephemeralで、Vista Enterpriseだけ49152~65535。

How to reserve a range of ephemeral ports on a computer that is running Windows Server 2003 or Windows 2000 Server
http://support.mi​crosoft.co​m/kb/812873/en-us

設定は、

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

にて変更可能と。

When you try to connect from TCP ports greater than 5000 you receive the error 'WSAENOBUFS (10055)'
http://support.mi​crosoft.co​m/kb/196271/en-us

試しに

#include <stdio.h>
#include <winsock2.h>

void main()
{
	WSADATA tWSAData;
	WSAStartup(MAKEWORD(2, 2), &tWSAData);

	sockaddr_in name;
	name.sin_family = AF_INET;
	name.sin_port = htons(5001);
	name.sin_addr.s_addr = INADDR_ANY;
	int namelen = sizeof(SOCKADDR);

	SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
	bind(s, (SOCKADDR*)&name, namelen);
	listen(s, 1);

	for(;;)
	{
		sockaddr_in name;
		name.sin_family = AF_INET;
		name.sin_port = htons(5001);
		name.sin_addr.s_addr = inet_addr("127.0.0.1");
		int namelen = sizeof(SOCKADDR);

		if(connect(socket(AF_INET, SOCK_STREAM, 0), (SOCKADDR*)&name, namelen) == SOCKET_ERROR)
		{
			break;
		}
		accept(s, (SOCKADDR*)&name, &namelen);
		printf("%d\n", ntohs(name.sin_port));
	}
	printf("->%d\n", WSAGetLastError());
}

とかしてポートを食い潰してみると、確かにWSAENOBUFS。
Linuxでは、

ip-sysctl.txt
Defines the local port range that is used by TCP and UDP to
choose the local port. The first number is the first, the
second the last local port number. Default value depends on
amount of memory available on the system:
> 128Mb 32768-61000
< 128Mb 1024-4999 or even less.
This number defines number of active connections, which this
system can issue simultaneously to systems not supporting
TCP extensions (timestamps). With tcp_tw_recycle enabled
(i.e. by default) range 1024-4999 is enough to issue up to
2000 connections per second to systems supporting timestamps.

128MB以上メモリを積んでいたら32768~61000。

man 7 ip
ip_local_port_range
Contains two integers that define the default local port range allocated to sockets. Allocation starts with the first number and ends with the second number. Note that these should not conflict with the ports used by masquerading (although the case is handled). Also arbitrary choices may cause problems with some firewall packet filters that make assumptions about the local ports in use. First number should be at least >1024, better >4096 to avoid clashes with well known ports and to minimize firewall problems.

設定は、

/proc/sys/net/ipv4/ip_local_port_range

にて変更可能と。
同様にポートを食い潰してみるとEADDRNOTAVAIL。
ふむ。 無糖ブラックは3本。
2007/04/12 Thu
いつもの電車に間に合いそうにないなくても豚角煮まんは食う。 無糖ブラックは4本。 鮭とばをかじりながら書類の仕上げ
あと、たこわさ。
すごい酒が飲みたい。
そしてやっぱりカレーまん。
2007/04/11 Wed
珍しく本社に来てた同期が遠巻きにこっちを見ながら隣と何か話しているのでなんだと思ったら、

「あれって病気?」

とか聞こえてきて吹いたのが昨日の話。小坂那也です。(挨拶)
病気って。
そんなにか。
否定したら病的と言い直されました。
それなら可。(変わんねぇよ) 春特有の感覚。
そして豚角煮まん。 新人教育担当とmain関数の話になり、

・戻り型は省略するとintになったような
・return;だと不定値が返ったような
・mainは他の関数と扱いが違ったような
・CとC++でも違ったような

とか、ひどく記憶が曖昧だったので試してみてまとめ。
コンパイラはBCC5.5.1。
システムによってはそもそも戻り型がないものもあるとかなんとか。

 {return 0;}{return;}{}
Cvoid main()W8081  
int main()  W8070
main()  W8070
C++void main()E2467  
int main() E2292 
main() E2292 
void foo()E2467  
int foo() E2292W8070
foo() E2292W8070

警告 W8070 foo.c xxx: 関数は値を返すべき(関数 main )
警告 W8081 foo.c xxx: void 関数は値を返してはならない(関数 main )
エラー E2292 foo.cpp xxx: 関数は値を返すべき(関数 main() )
エラー E2467 foo.cpp xxx: 'main()' は値を返せない(関数 main() )
無糖ブラックは3本。
やるせない。
まだまだカレーまん。
2007/04/10 Tue
シャワーを浴びて。
もってけ!セーラーふくをmp3変換して。
TopTangentにコピーして。
TEPRAをカバンに詰め込んで。
豚角煮まんをくわえて。
出発だ。 引き続きメイクファイルをこねくり回す。
メンテしやすくしようと重複記述を極力減らすためにincludeを多用しているうちに自分にしかメンテできないシロモノになってきたので単純な構成に書き直す。
まぁ、こんなもんか。
一応まだこれが仕事だという自覚はあるようです。安心した! これはひどいシーケンスですね。 なんでXML::Simpleだけ4/7に更新されてるのっさ。

$ls -l /usr/local/lib/perl5/site_perl/5.8.6/XML
total 324
drwxr-xr-x    2 root     root         4096 Nov 30  2005 DOM
-r--r--r--    1 root     root       110674 Jul 26  2005 DOM.pm
-r--r--r--    1 root     root        12109 Nov  6  2004 DTDParser.pm
-r--r--r--    1 root     root        19968 Oct 22  2003 ESISParser.pm
drwxr-xr-x    2 root     root         4096 Nov 30  2005 Handler
-r-xr-xr-x    1 root     root        20698 May 13  2005 NamespaceSupport.pm
drwxr-xr-x    2 root     root         4096 Dec 31  2005 Parser
drwxr-xr-x    2 root     root         4096 Nov 30  2005 PatAct
-r--r--r--    1 root     root         2576 Oct 22  2003 Perl2SAX.pm
-r--r--r--    1 root     root         6065 Jun 20  2001 RegExp.pm
drwxr-xr-x    3 root     root         4096 Nov 30  2005 SAX
-r--r--r--    1 root     root         9239 Oct 25  2005 SAX.pm
-r--r--r--    1 root     root         6486 Oct 22  2003 SAX2Perl.pm
drwxr-xr-x    2 root     root         4096 Apr  7 03:37 Simple
-r--r--r--    1 root     root        91171 Oct 30 17:28 Simple.pm
無糖ブラックは4本。
2007/04/09 Mon
今週も豚角煮まんから始まる。
豚角煮まんから始まるミラクルだってあるよね。(ねぇよ)
歌詞を検索したら英訳の仕事をした普通の人の日記がでてきて吹いた。
きゅいん!って! 日がな一日makeの構成をこねくり回していたようなそんな日。
無糖ブラックは4本。 全社的に残業について規制が設けられる模様。
残業手当を割増にした上で時間を削減とかなんとか。はぁ。
体制を見直して負担のばらつきをどうにかすることを先に考えればいいのに。
そんなことより自主サービス残業を許可する制度をつくってくれと言いたい。というか次の面談で言う。 とりあえず定時退社をしてみる。
会社の前でカレーまんをかじりながら降りしきる雨を茫と眺める。
精神衛生上良くない。
2007/04/08 Sun
文中にtextareaを挿入するために改行コードを挿入するマクロを追加したりとかスクリプトを微修正。 秋葉原。
本当にオークションでしかものが手に入らなくなってきたなとげんなりする。
中古メモリを買おうとして店員の対応にげんなりする。
マウスを7個買って帰る。(会社用) mixiの更新表示がおかしくなっていてなんだえー微修正したせいか?と思ったら、どうも借鯖のPerlが更新されてモジュールが追加された様子。そんなアナウンスなかったのですが。
ソート部分をいじったモジュールをローカルに置いて使っていたので、追加されたことで本来の形で出力されてしまっていたと。そして本来の形だと誤認識されると。
とりあえずローカル側から無理矢理読み込むようにしてお茶を濁す。
そもそもXML::Simpleを使っているのが悪いといえば悪いのだけれど。ファイルの先頭7件しか読まないてのはどうなのさ。dc:dateのTZDも無視されるし。
http://www.w3.org​/TR/NOTE-datetime
2007/04/07 Sat
半日くらい寝ていた気がする。 出かけようとしたけれど微妙に雨が降ってきたので電車で出かけるのをやめて90度折れ曲がって線路沿いをてくてく。
PC DEPOTで会社で使うPC接続専用TEPRAとかを買ったりなんだり。SR-3500P。 会社で廃棄されるところをサルベージしてきたCF-M1ER。
年末年始の放浪ではホテルの予約に地図の閲覧にと活躍しましたが、内臓バッテリが5分と持たないのは悲しすぎるのでバッテリの購入を考えたり、でも98ノートじゃないしなと思ったり。
とりあえず備忘録。
バッテリの種類は以下。

CF-VZSU10J(標準バッテリ)
CF-VZSU11J(大容量バッテリ)
CF-VZSA44J(拡張バッテリ)
http://www.mylets​.jp/option/index1.htm​l

ヤフオクでへたったバッテリを購入して、バッテリリフレッシュサービスを利用するのがいいんじゃなかろうかと。
ただし、拡張バッテリは部品不足とかで終了している模様。
大容量バッテリの容量が標準バッテリの3倍とかあるようなので、どうせなら大容量バッテリか。


大容量バッテリと同容量の補助バッテリなんてのも。

バッテリといえば、sigmarionIIIの予備バッテリも押さえておきたいところ。
http://www.rowa.c​o.jp/cabinet/form.cgi?no=652
http://www.rowa.c​o.jp/cabinet/form.cgi?no=711
2007/04/06 Fri
豚角煮まんがないのでジューシー肉まん。 ルーチンワークと化した仕事以外の生活を淡々と記録し続けるのも飽きてきたのでというかルーチンそのものには飽きていないのですがまぁとにかくそれはそれとして、メモを残していたり残していなかったり残していないので忘却したり残していてもどこかにやったか忘却したりするような事柄を書いたり書かなかったり酒を飲んでは虚ろな目をしてみることにする。
最後のは余計です。
その前のは今までと変わらないし。
そんな感じで適当に。 structなコンテナに対してalgorithmのsortを使用すると、VisualC++2003では

algorithm(1719): error C2676: 二項演算子 '<' : 'std::allocator<_Ty>::value_type' は、この演算子または定義済の演算子に適切な型への変換の定義を行いません。 (新しい動作; ヘルプを参照)
algorithm(1720): error C2676: 二項演算子 '<' : 'std::allocator<_Ty>::value_type' は、この演算子または定義済の演算子に適切な型への変換の定義を行いません。 (新しい動作; ヘルプを参照)
algorithm(1719): error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : 'const std::_Tree<_Traits> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1720): error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : 'const std::_Tree<_Traits> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1719): error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : 'const std::deque<_Ty,_Ax> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1720): error C2784: 'bool std::operator <(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : 'const std::deque<_Ty,_Ax> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1719): error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : 'const std::list<_Ty,_Ax> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1720): error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : 'const std::list<_Ty,_Ax> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1719): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : 'const std::pair<_Ty1,_Ty2> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1720): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : 'const std::pair<_Ty1,_Ty2> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1719): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : 'const std::reverse_iterator<_RanIt> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1720): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : 'const std::reverse_iterator<_RanIt> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1719): error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : 'const std::vector<_Ty,_Ax> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1720): error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : 'const std::vector<_Ty,_Ax> & 用のテンプレート引数を 'std::allocator<_Ty>::value_type' から減少できませんでした。
algorithm(1720): fatal error C1903: 直前のエラーを修復できません。コンパイルを中止します。

gcc3.4.3だと

stl_algo.h: In function `void std::partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]':
stl_algo.h:2470:   instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Size = int]'
stl_algo.h:2553:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_algo.h:2274: error: no match for 'operator<' in '(&__i)->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]() < (&__first)->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]()'
stl_algo.h: In function `const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&) [with _Tp = foobar]':
stl_algo.h:2482:   instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Size = int]'
stl_algo.h:2553:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_algo.h:90: error: no match for 'operator<' in '__a < __b'
stl_algo.h:91: error: no match for 'operator<' in '__b < __c'
stl_algo.h:93: error: no match for 'operator<' in '__a < __c'
stl_algo.h:97: error: no match for 'operator<' in '__a < __c'
stl_algo.h:99: error: no match for 'operator<' in '__b < __c'
stl_algo.h: In function `_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, _Tp) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Tp = foobar]':
stl_algo.h:2482:   instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Size = int]'
stl_algo.h:2553:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_algo.h:2014: error: no match for 'operator<' in '(&__first)->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]() < __pivot'
stl_algo.h:2482:   instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Size = int]'
stl_algo.h:2553:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_algo.h:2017: error: no match for 'operator<' in '__pivot < (&__last)->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]()'
stl_algo.h: In function `void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]':
stl_algo.h:2199:   instantiated from `void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
stl_algo.h:2554:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_algo.h:2117: error: no match for 'operator<' in '__val < (&__first)->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]()'
stl_algo.h: In function `void std::__unguarded_linear_insert(_RandomAccessIterator, _Tp) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Tp = foobar]':
stl_algo.h:2123:   instantiated from `void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
stl_algo.h:2199:   instantiated from `void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
stl_algo.h:2554:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_algo.h:2070: error: no match for 'operator<' in '__val < (&__next)->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]()'
stl_heap.h: In function `void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Distance = int, _Tp = foobar]':
stl_heap.h:364:   instantiated from `void std::make_heap(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
stl_algo.h:2272:   instantiated from `void std::partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
stl_algo.h:2470:   instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Size = int]'
stl_algo.h:2553:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_heap.h:216: error: no match for 'operator<' in '(&std::reverse_iterator<_Iterator>::operator+(typename std::iterator_traits<_Iterator>::difference_type) const [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >](__secondChild))->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]() < (&std::reverse_iterator<_Iterator>::operator+(typename std::iterator_traits<_Iterator>::difference_type) const [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]((__secondChild - 1)))->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]()'
stl_heap.h: In function `void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Distance = int, _Tp = foobar]':
stl_heap.h:227:   instantiated from `void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Distance = int, _Tp = foobar]'
stl_heap.h:364:   instantiated from `void std::make_heap(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
stl_algo.h:2272:   instantiated from `void std::partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
stl_algo.h:2470:   instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Size = int]'
stl_algo.h:2553:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_heap.h:121: error: no match for 'operator<' in '(&std::reverse_iterator<_Iterator>::operator+(typename std::iterator_traits<_Iterator>::difference_type) const [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >](__parent))->std::reverse_iterator<_Iterator>::operator* [with _Iterator = __gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > >]() < __value'

とか怒られる。
<演算子がないとのことなので

struct foobar
{
    int foo, bar;

    bool operator <(foobar& r)
    {
        return foo < r.foo;
    }
};

のようにすると、VisualC++では怒られなくなるが、gccでは

stl_algo.h: In function `const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&) [with _Tp = foobar]':
stl_algo.h:2482:   instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >, _Size = int]'
stl_algo.h:2553:   instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = std::reverse_iterator<__gnu_cxx::__normal_iterator<foobar*, std::vector<foobar, std::allocator<foobar> > > >]'
foobar.cc:xxx:   instantiated from here
stl_algo.h:90: error: no match for 'operator<' in '__a < __b'
foobar.cc:xxx: note: candidates are: bool foobar::operator<(foobar&)
stl_algo.h:91: error: no match for 'operator<' in '__b < __c'
foobar.cc:xxx: note: candidates are: bool foobar::operator<(foobar&)
stl_algo.h:93: error: no match for 'operator<' in '__a < __c'
foobar.cc:xxx: note: candidates are: bool foobar::operator<(foobar&)
stl_algo.h:97: error: no match for 'operator<' in '__a < __c'
foobar.cc:xxx: note: candidates are: bool foobar::operator<(foobar&)
stl_algo.h:99: error: no match for 'operator<' in '__b < __c'
foobar.cc:xxx: note: candidates are: bool foobar::operator<(foobar&)

とかまだ怒られる。
これにSTLFiltを適用すると、

BD Software STL Message Decryptor v2.47a for gcc
stl_algo.h: In function
   `const foobar & __median(const foobar &, const foobar &, const foobar &)':
    [STL Decryptor: Suppressed 2 more STL standard header messages]
foobar.cc:xxx:   instantiated from here
stl_algo.h:90: error: no match for 'operator<' in '__a < __b'
stl_algo.h:91: error: no match for 'operator<' in '__b < __c'
stl_algo.h:93: error: no match for 'operator<' in '__a < __c'
stl_algo.h:97: error: no match for 'operator<' in '__a < __c'
stl_algo.h:99: error: no match for 'operator<' in '__b < __c'

STL Decryptor reminders:
    Use the /hdr:L option to see all suppressed standard lib headers
    Use the /cand:L option to see all suppressed template candidates

のようになる。
constでないのが原因なようなので、

struct foobar
{
    int foo, bar;

    bool operator <(const foobar& r) const
    {
        return foo < r.foo;
    }
};

とかそんな感じに。 STLFilt。
STL絡みのよくわからないエラーメッセージをどうにかするフィルタ。
gccでしか試していないけど、VisualC++にも対応している模様。
アーカイブに含まれるgfiltとgSTLFilt.plを適当に配置して、gfiltの下記あたりを環境に合わせて書き換える。

COMPILER=c++                            # Your g++ compiler command
STLFILT=$HOME/gSTLFilt.pl               # Where you've placed the Perl script

あとはコンパイラをgfiltに置き換えてコンパイルするだけ。
エラーメッセージがどうにかなって出力されるので、唸ったり納得したりする。
http://www.bdsoft​.com/tools/stlfilt.ht​ml