#ifndef errTCC
#define errTCC


template <
class Reason,
class Position,
class Context
>
const char* combine (
	const Reason& rsn, 
	const Position& pos, 
	const Context& ctx
) {
    std::string w;
    static std::string whatstr;
    whatstr = std::string("");
    w = pos.tell();
    if (!w.empty()) whatstr += w +  ": ";
    whatstr += rsn.tell();
    w = ctx.tell();
    if (!w.empty()) whatstr += " in " + w;
    return whatstr.c_str();
}

template <
class SysCategory,
class Reason,
class Position,
class Context
>
CException <SysCategory, Reason, Position, Context> :: CException (const Reason rsn, const Position pos, const Context ctx):
        Reason (rsn),
	SysCategory (combine <Reason, Position, Context> (rsn, pos, ctx) )
{}

template <
class SysCategory,
class Reason,
class Position,
class Context
>
CException <SysCategory, Reason, Position, Context> :: CException (const Position pos, const Context ctx):
	SysCategory (combine <Reason, Position, Context> (Reason(0), pos, ctx) )
{}
template <
class SysCategory,
class Reason,
class Position,
class Context
>
ExNullPosition CException <SysCategory, Reason, Position, Context> :: nopos_;
template <
class SysCategory,
class Reason,
class Position,
class Context
>
ExNullContext CException <SysCategory, Reason, Position, Context> :: noctx_;

#endif
