3 #include <boost/optional.hpp> 
    5 #define BOOST_SPIRIT_USE_PHOENIX_V3 
    6 #include <boost/spirit/include/phoenix_bind.hpp> 
    7 #include <boost/spirit/include/phoenix_core.hpp> 
    8 #include <boost/spirit/include/phoenix_operator.hpp> 
    9 #include <boost/spirit/include/qi.hpp> 
   10 #include <boost/spirit/include/qi_parse.hpp> 
   12 #include "../typetraits.h" 
   17     namespace qi = boost::spirit::qi;
 
   18     namespace px = boost::phoenix;
 
   24         template<
typename Attr>
 
   26             std::cout << 
"Checking mod(" << n << 
", " << Attr(
carl::pow(Attr(10), 
exp)) << 
")" << std::endl;
 
   31         template<
typename Attr>
 
   48         template <
typename It>
 
   50             return qi::real_policies<T>::parse_dot(first, last);
 
   52 #if BOOST_VERSION >= 105900 
   53         template <
typename It, 
typename Attr>
 
   54         static bool parse_frac_n(It& first, 
const It& last, Attr& attr, 
int& frac_digits) {
 
   58                 int local_frac_digits;
 
   59                 bool res = qi::real_policies<T>::parse_frac_n(first, last, local_attr, local_frac_digits);
 
   60                 if (!res) 
return false;
 
   67             return qi::real_policies<T>::parse_frac_n(first, last, attr, frac_digits);
 
   70         template <
typename It, 
typename Attr>
 
   75                 bool res = qi::real_policies<T>::parse_frac_n(first, last, local_attr);
 
   77                 if (!res) 
return false;
 
   82             return qi::real_policies<T>::parse_frac_n(first, last, attr);
 
   85         template <
typename It, 
typename Attr>
 
   86         static bool parse_exp_n(It& first, 
const It& last, Attr& attr_) {
 
   87             bool res = qi::real_policies<T>::parse_exp_n(first, last, attr_);
 
   88             if (!res) 
return false;
 
   92         template <
typename It, 
typename Attr>
 
   96         template <
typename It, 
typename Attr>
 
  111     template<
typename T, 
typename Iterator = std::
string::const_iterator>
 
  124     template<
typename Parser, 
typename T>
 
  126         auto it = input.begin();
 
  127         if (
parse(it, input.end(), Parser(), output)) {
 
  128             return it == input.end();
 
  132     template<
typename Parser, 
typename T, 
typename S>
 
  133     bool parse_impl(
const std::string& input, T& output, 
const S& skipper) {
 
  134         auto it = input.begin();
 
  135         if (phrase_parse(it, input.end(), Parser(), skipper, output)) {
 
  136             return it == input.end();
 
  143         return parse_impl<DecimalParser<T>>(input, output);
 
  147         return parse_impl<DecimalParser<T>>(input, output);
 
  151         return parse_impl<RationalParser<T>>(input, output, 
Skipper());
 
States if a type represents a subset of all integers.
carl is the main namespace for the library.
cln::cl_I mod(const cln::cl_I &a, const cln::cl_I &b)
Calculate the remainder of the integer division.
Interval< Number > exp(const Interval< Number > &i)
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
T parse(const std::string &n)
Interval< Number > pow(const Interval< Number > &i, Integer exp)
bool parseDecimal(const std::string &input, T &output)
bool parseRational(const std::string &input, T &output)
bool parse_impl(const std::string &input, T &output)
bool parseInteger(const std::string &input, T &output)
PositionIteratorType Iterator
bool operator()(const Attr &n, std::size_t exp)
bool operator()(const Attr &, std::size_t)
Specialization of qi::real_policies for our rational types.
static constexpr bool T_is_int
static bool parse_exp_n(It &first, const It &last, Attr &attr_)
static bool parse_dot(It &first, const It &last)
static bool parse_frac_n(It &first, const It &last, Attr &attr)
static constexpr bool allow_leading_dot
static bool parse_nan(It &, const It &, Attr &)
static constexpr bool expect_dot
static constexpr bool allow_trailing_dot
static bool parse_inf(It &, const It &, Attr &)
Parses (signed) integers.
Parses decimals, including floating point and scientific notation.
Parses rationals, being two decimals separated by a slash.
DecimalParser< T > number
qi::rule< Iterator, T(), Skipper > main
T makeRational(const T &a, const boost::optional< T > &b) const