xtd
xtd
is a tiny replacement (a single file of about 1.6k lines) for the functional
(and cmath
)
header(s) of the standard C++ library. If you've got any problem with
it please submit a bug report.
std
algorithms. The way we have designed classes in xtd
relies
on the static C++ object-oriented paradigm (SCOOP) as described
here.
std C++ | xtd |
remove_if(L.begin(), L.end(), compose2(logical_and<bool>(), bind2nd(greater<int>(), 100), bind2nd(less<int>(), 1000))); |
remove_if(L.begin(), L.end(), x > 100 && x < 1000); |
g++ -Wall -ansi -pedantic tour.cc
)icc -w1 -Xc tour.cc
)como -lm -DXTD_USE_COMO tour.cc
)-DXTD_USE_COMO
xcos
in addition to cos
, etc.cos(x,x)
std::cout << to<int>(pow(cos,2) + pow(sin,2))(x) << std::endl
xtd::cos(x)
is an expressionxtd::cos(x)(51) evaluates the expression
xtd::cos(51)
is fine(pow(cos(x), 2) + pow(sin(x), 2.0f))
first
and second
are access functions to pair-like class memberstrue
and false
: (true == x)
is okf = for_each(i1,i2, fun(f)(x + 1))
is ok if f
is a function objectternary(x, 1+y, 1-y) with x
expecting bool
data works fine
xtd::fun(..)
(2*x)(x+1) means (2*(x+1))
and (x*y+1)(3*x, x+2)
means ((3*x)*(x+2)+1)
- expressions accept some constant values (the ones whose type is
int
, float
, or double
)
without precising cst(..)
- type promotion:
(x + 3.14f)
with x
being a placeholder for int
data will give float
- ability to define meta-function objects (such as
struct sqr { template<class T> T operator()(T t) const {return t*t;} };
) and to involve them in expressions: fun(sqr)(x + 1)
is ok
std
onesexpr
(so that expression templates are disambiguated)cst
cst(2) * x + cst(1)
std::mem_ptr
does)