Что-то много всякой фигнёй в последнее время страдаем (особенно философской).
Вот фрагмент кода (слияние двух отсортированных последовательностей).
Задача --
красиво убить goto.
template <class Range>
template <class Collector>
typename ResultAttributes<typename Collector::FunctorType>::ResultType
UnionGenType<Range>::operator () (Collector collector) const
{
Range a=a_,b=b_;
typedef typename Collector::FunctorType FunctorType;
FunctorType fun(collector);
if( !a ) goto finish_b;
if( !b ) goto finish_a;
for(;;)
switch( Cmp(*a,*b) )
{
case CmpLess :
{
fun(*a);
++a;
if( !a ) goto finish_b;
}
break;
case CmpGreater :
{
fun(*b);
++b;
if( !b ) goto finish_a;
}
break;
case CmpEqual :
{
fun(*a);
++a;
++b;
if( !a ) goto finish_b;
if( !b ) goto finish_a;
}
}
finish_a:
for(; +a ;++a) fun(*a);
goto finish;
finish_b:
for(; +b ;++b) fun(*b);
finish:
return ResultAttributes<FunctorType>::GetResult(fun);
}