Program Listing for File device_allocator.h

Return to documentation for file (thrust/device_allocator.h)

/*
 *  Copyright 2008-2013 NVIDIA Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */


#pragma once

#include <thrust/detail/config.h>
#include <thrust/device_new_allocator.h>
#include <limits>
#include <stdexcept>

namespace thrust
{

template<typename T> class device_allocator;

template<>
  class device_allocator<void>
{
  public:
    typedef void                              value_type;

    typedef device_ptr<void>                  pointer;

    typedef device_ptr<const void>            const_pointer;

    typedef std::size_t                       size_type;

    typedef pointer::difference_type difference_type;

    template<typename U>
      struct rebind
    {
      typedef device_allocator<U> other;
    }; // end rebind
}; // end device_allocator<void>

template<typename T>
  class device_allocator
    : public device_new_allocator<T>
{
  public:
    template<typename U>
      struct rebind
    {
      typedef device_allocator<U> other;
    }; // end rebind

    __host__ __device__
    inline device_allocator() {}

    __host__ __device__
    inline device_allocator(device_allocator const&) {}

    template<typename U>
    __host__ __device__
    inline device_allocator(device_allocator<U> const&) {}
}; // end device_allocator

} // end thrust