Open sehe opened 11 years ago
PS.
Also, I think you'd need to use either std::declval<X1>()
or std::forward<X1>(a)
instead of just a + b
in decltype, lest you run into issues with inaccessible copy constructors.
Thank you for such awesome feedback sehe.
You do run into issues with ctors. Thus why we use declval. I learnt this the hard way. Would you be keen in contributing or at least critquing and raising issues as you find them your advice and comments have been awesome.
Well, sure. I was mostly being skeptical about the need for a library here. I usually write my traits as I go.
Also, it appears I was misremembering the purposes of the new Boost Libraries in 1.54.0 beta: TTI is nice, but Boost TypeErasure seems to have precisely what you're implementing:
addable<T, U = T, R = T>
subtractable<T, U = T, R = T>
multipliable<T, U = T, R = T>
dividable<T, U = T, R = T>
modable<T, U = T, R = T>
bitandable<T, U = T, R = T>
bitorable<T, U = T, R = T>
bitxorable<T, U = T, R = T>
left_shiftable<T, U = T, R = T>
right_shiftable<T, U = T, R = T>
equality_comparable<T, U = T>
less_than_comparable<T, U = T>
add_assignable<T, U = T>
subtract_assignable<T, U = T>
multiply_assignable<T, U = T>
divide_assignable<T, U = T>
mod_assignable<T, U = T>
bitand_assignable<T, U = T>
bitor_assignable<T, U = T>
bitxor_assignable<T, U = T>
left_shift_assignable<T, U = T>
right_shift_assignable<T, U = T>
ostreamable<Os = std::ostream, T = _self>
istreamable<Is = std::istream, T = _self>
Looks pretty comprehensive to me. And there's unary ops, function calleables etc. too :)
Oh we'll still fun to write and learning heaps so I will finish it
Sent from my iPad
On 15/06/2013, at 2:46 AM, sehe notifications@github.com wrote:
Well, sure. I was mostly being skeptical about the need for a library here. I usually write my traits as I go.
Also, it appears I was misremembering the purposes of the new Boost Libraries in 1.54.0 beta: TTI is nice, but Boost TypeErasure seems to have precisely what you're implementing:
Table 33.3. Binary Operators
addable subtractable multipliable dividable modable bitandable bitorable bitxorable left_shiftable right_shiftable equality_comparable less_than_comparable add_assignable subtract_assignable multiply_assignable divide_assignable mod_assignable bitand_assignable bitor_assignable bitxor_assignable left_shift_assignable right_shift_assignable ostreamable istreamable Looks pretty comprehensive to me. And there's unary ops, function calleables etc. too :)
— Reply to this email directly or view it on GitHub.
The naming of the traits seems... wrong.
E.g. 'has_addition_operator' would have been more aptly approximated by something like this:
Note
static constexpr
>enum
trick (we're not writing c++03 anyways)has
is only used in decltype so there is no need for body definitionsAlternatively, you could rename the traits, in which case I'd do something like this:
Seems much quicker. Of course, generalize for asymmetrical binary ops