   }
   catch(std::bad_alloc)
   {
+    std::cout << "Caught std::bad_alloc" << std::endl;
     return 0;
   }
 


      if(raw_ptr)
      {
        kernel<<<100,256>>>(raw_ptr, n); // generate unsorted values

        thrust::cuda::pointer<int> begin = thrust::cuda::pointer<int>(raw_ptr);
        thrust::cuda::pointer<int> end   = begin + n;

        // sort the data using our special allocator
        // if temporary memory is required during the sort,

#include <thrust/functional.h>
#include <thrust/tabulate.h>
#include <thrust/sort.h>
#include <thrust/memory.h>
#include <thrust/system/cuda/memory.h>

#include <new> // for std::bad_alloc
#include <iostream>

// This example demonstrates how to intercept calls to malloc
// and free to implement a fallback for cudaMalloc.
