So calling a special function with a specific policy is just a matter of
defining the policy type to use and passing it as the final parameter.
For example, suppose we want tgamma
to behave in a C-compatible fashion and set ::errno when an error occurs, and never
throw an exception:

Alternatively, for ad hoc use, we can use the make_policy
helper function to create a policy for us: this usage is more verbose,
so is probably only preferred when a policy is going to be used once only:

#include<boost/math/special_functions/gamma.hpp>usingboost::math::tgamma;intmain(){// using namespace boost::math::policies; // orusingboost::math::policies::errno_on_error;usingboost::math::policies::make_policy;usingboost::math::policies::pole_error;usingboost::math::policies::domain_error;usingboost::math::policies::overflow_error;usingboost::math::policies::evaluation_error;errno=0;std::cout<<"Result of tgamma(30000) is: "<<boost::math::tgamma(30000,make_policy(domain_error<errno_on_error>(),pole_error<errno_on_error>(),overflow_error<errno_on_error>(),evaluation_error<errno_on_error>()))<<std::endl;// Check errno was set:std::cout<<"errno = "<<errno<<std::endl;// and again with evaluation at a pole:std::cout<<"Result of tgamma(-10) is: "<<boost::math::tgamma(-10,make_policy(domain_error<errno_on_error>(),pole_error<errno_on_error>(),overflow_error<errno_on_error>(),evaluation_error<errno_on_error>()))<<std::endl;// Check errno was set:std::cout<<"errno = "<<errno<<std::endl;}