Skip to content

Instantly share code, notes, and snippets.

@jaredhoberock
Created January 26, 2012 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredhoberock/faf3464335e9470ffa2a to your computer and use it in GitHub Desktop.
Save jaredhoberock/faf3464335e9470ffa2a to your computer and use it in GitHub Desktop.
Reverse a string using Thrust
// thrust.googlecode.com
#include <thrust/device_vector.h>
#include <thrust/reverse.h>
#include <iostream>
#include <iterator>
int main()
{
char A[] = "string to reverse";
thrust::device_vector<char> reverse_me(A, A + sizeof(A));
thrust::reverse(reverse_me.begin(), reverse_me.end());
std::cout << A << " reversed is ";
thrust::copy(reverse_me.begin(), reverse_me.end(), std::ostream_iterator<char>(std::cout));
std::cout << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment