こんな関数作ったよ。
■ このスレッドは過去ログ倉庫に格納されています
0005デフォルトの名無しさん
NGNG// 便利かもしれない。
// とかね。こんな感じで。
template< class T > class Pitcher {
public:
T success,result;
inline Pitcher( T v = 0 ) { result = success = v; }
inline Pitcher<T>& operator<<=( T v ) {
return check( v ), *this;
}
inline void check( T v ) {
if( success != v ) throw( result = v );
}
};
// 使用例。
#include <stdio.h>
void main( int argc, char* argv[] ) {
Pitcher<bool> result( true );
try {
result <<= argc > 1;
printf("# %s\n", argv[1] );
} catch( bool ) {
printf("exception %d!\n", result.result );
}
}
■ このスレッドは過去ログ倉庫に格納されています