]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/compute/container/detail/scalar.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / compute / container / detail / scalar.hpp
CommitLineData
7c673cae
FG
1//---------------------------------------------------------------------------//
2// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3//
4// Distributed under the Boost Software License, Version 1.0
5// See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt
7//
8// See http://boostorg.github.com/compute for more information.
9//---------------------------------------------------------------------------//
10
11#ifndef BOOST_COMPUTE_CONTAINER_DETAIL_SCALAR_HPP
12#define BOOST_COMPUTE_CONTAINER_DETAIL_SCALAR_HPP
13
14#include <boost/compute/buffer.hpp>
b32b8144 15#include <boost/compute/event.hpp>
7c673cae
FG
16#include <boost/compute/detail/read_write_single_value.hpp>
17
18namespace boost {
19namespace compute {
20namespace detail {
21
22// scalar<T> provides a trivial "container" that stores a
23// single value in a memory buffer on a compute device
24template<class T>
25class scalar
26{
27public:
28 typedef T value_type;
29
30 scalar(const context &context)
31 : m_buffer(context, sizeof(T))
32 {
33 }
34
35 ~scalar()
36 {
37 }
38
39 T read(command_queue &queue) const
40 {
41 return read_single_value<T>(m_buffer, 0, queue);
42 }
43
b32b8144 44 event write(const T &value, command_queue &queue)
7c673cae 45 {
b32b8144 46 return write_single_value<T>(value, m_buffer, 0, queue);
7c673cae
FG
47 }
48
49 const buffer& get_buffer() const
50 {
51 return m_buffer;
52 }
53
54private:
55 buffer m_buffer;
56};
57
58} // end detail namespace
59} // end compute namespace
60} // end boost namespace
61
62#endif // BOOST_COMPUTE_CONTAINER_DETAIL_SCALAR_HPP