Add int()
,'float() and
str()` implicit conversions ref #4477.
This commit is contained in:
parent
bb3106d04f
commit
3422472c7d
2 changed files with 30 additions and 8 deletions
|
@ -209,14 +209,17 @@ struct unary_function_types_ : x3::symbols<unary_function_impl>
|
||||||
{
|
{
|
||||||
unary_function_types_()
|
unary_function_types_()
|
||||||
{
|
{
|
||||||
add("sin", sin_impl()) //
|
add("sin", sin_impl()) //
|
||||||
("cos", cos_impl()) //
|
("cos", cos_impl()) //
|
||||||
("tan", tan_impl()) //
|
("tan", tan_impl()) //
|
||||||
("atan", atan_impl()) //
|
("atan", atan_impl()) //
|
||||||
("exp", exp_impl()) //
|
("exp", exp_impl()) //
|
||||||
("log", log_impl()) //
|
("log", log_impl()) //
|
||||||
("abs", abs_impl()) //
|
("abs", abs_impl()) //
|
||||||
("length", length_impl()) //
|
("length", length_impl()) //
|
||||||
|
("int", int_impl()) //
|
||||||
|
("float", float_impl()) //
|
||||||
|
("str", str_impl()) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} const unary_func_types;
|
} const unary_func_types;
|
||||||
|
|
|
@ -89,6 +89,25 @@ struct length_impl
|
||||||
value_type operator()(value_type const& val) const { return val.to_unicode().length(); }
|
value_type operator()(value_type const& val) const { return val.to_unicode().length(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// str
|
||||||
|
struct str_impl
|
||||||
|
{
|
||||||
|
value_type operator()(value_type const& val) const { return val.to_unicode(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// int
|
||||||
|
struct int_impl
|
||||||
|
{
|
||||||
|
value_type operator()(value_type const& val) const { return val.to_int(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// float
|
||||||
|
struct float_impl
|
||||||
|
{
|
||||||
|
value_type operator()(value_type const& val) const { return val.to_double(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// min
|
// min
|
||||||
inline value_type min_impl(value_type const& arg1, value_type const& arg2)
|
inline value_type min_impl(value_type const& arg1, value_type const& arg2)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue