Closed kimwalisch closed 6 years ago
One method of doing this in C++98 would be to derive from the desired type:
template <typename T>
class divider_branchfree : public divider<T, libdivide::BRANCHFREE>
{
// must duplicate the constructors for `divider<T>` in here
};
Unfortunately, C++98 doesn't support the hoisting of base-class constructors with the using
keyword like C++11 does, but this stucture achieves the desired user-level syntax.
One method of doing this in C++98 would be to derive from the desired type:
I tried exactly that a few months ago but I failed. If you can make it work that would be great!
I have now implemented this for C++11 in only 4 lines of code. I won't implement it in C++98 though, I tried to do it in 2016 but the code was a mess and ultimately I could not make it work.
I have actually decided to use libdivide::branchfree_divider<T>
instead of libdivide::divider_branchfree<T>
as I suggested back in 2016.
I am thinking about documenting the branchfree in README.md
because most people do not know this functionality exists in libdivide as it is not documented on http://libdivide.com.
The current API for using the branchfree divider in C++ is a little too cumbersome in my opinion:
I think that:
would be nicer. Using C++11 this could be implemented using:
It would be nice to find a solution for C++98 as well.