Type deduction for ternary operator

refs #53
Type deduction for builtin functions

refs #53

Current implementation assumes that the return type of a builtin
function is the common type (in std::common_type sense) of its
arguments. This should work in most cases but could fail for some
functions.