make unary_function/binary_function optional (C++11) #624
Comments
Would you be interested in pull requests that can non-invasively start making use of C++11?
|
@jaredhoberock How is your plan to continue the development Thrust with C+11 support? |
This would really help when using templated functors in combination with zip iterators, e.g:
If
|
If you guys want to work out a pull request for this one, I'll review and merge. |
@jaredhoberock Would you like to have a global #define switch like |
I'd prefer not introducing new switches. I assume if people are already opting into something like |
Would c++11 support render |
There's a lot of non-standard stuff in |
Yes, it only uses |
regarding I don't use Visual Studio, but it seems like that at least up to VS2013, |
That's fine, I wouldn't want to rely on C++11 features unless that macro reported they were available. |
Yet, these C++11 features are available on VS. In my platform independent project, I still have to derive from I know it looks ugly, but how about using the aforementioned preprocessor switch
I could then globally define in my code:
This would change nothing for GCC, but would enable Thrust's C++11 features for VS. |
That's fine -- we needn't engage in heroics to enable this feature. VS2013 users can just use |
@jaredhoberock I updated my comment |
Thrust supports more compilers than just gcc and the Microsoft compiler. It's very expensive to track down which language features are available on which versions of the different compilers. Explicitly defining a hypothetical Suppose a compiler supported C++11 feature A, but not B and therefore sets a conservative value for There is already a standard means to introspect whether language features are available by using the |
I definitely see your point and agree. |
There may be a compromise. I would make an exception for the feature test macros recommended by SD6 because they are a near standard and Thrust would not have to create its own preprocessor symbols to introspect. If there is an appropriate feature test macro for |
There is one, but then again, we need a solution to detect c++11 for other features as well (see variadic tuple). |
This is intended for the C++11 milestone:
Can requiring that
unary_function
andbinary_function
be the base class for a UnaryFunction or BinaryFunction in Thrust algorithms be made optional?Not only does this remove the need for deriving from these types, I think (I'm just now starting to really learn C++11) that it also removes the need for writing constructors for small functors since they can instead be instantiated with aggregate initialization once the functors would no longer have a base class.
becomes:
I've already made this change in my private copy of Thrust via
std::result_of
inthrust/detail/type_traits/result_of.h
.The text was updated successfully, but these errors were encountered: