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
| #include <vector>
#include <stdexcept>
int main()
{
std::vector<int> v(10);
somme(v.begin(),v.end(),make_simple_contrat(trace_policy()));
somme(v.begin(),v.end(),make_strict_contrat(3,trace_policy()));
try
{
somme(v.begin(),v.end(),make_strict_contrat(15,exception_policy<std::invalid_argument>()));
}
catch(std::exception const&e_)
{
std::cout<<"EXCEPTION : "<<e_.what()<<"\n";
}
try
{
somme(v.end(),v.begin(),make_simple_contrat(exception_policy<std::invalid_argument>()));
}
catch(std::exception const&e_)
{
std::cout<<"EXCEPTION : "<<e_.what()<<"\n";
}
return 0;
} |