stdgpu/iterator.h Source File — stdgpu Latest documentation (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef STDGPU_ITERATOR_H

17#define STDGPU_ITERATOR_H

18

28#include <thrust/detail/pointer.h>

29#include <thrust/detail/reference.h>

30

33

34namespace stdgpu

35{

36

42template

43using device_ptr = thrust::pointer<T, thrust::device_system_tag>;

44

50template

51using host_ptr = thrust::pointer<T, thrust::host_system_tag>;

52

60template

63

71template

74

83template

86

94template <>

97

105template

108

116template

119

127template

130

138template

141

149template

152

160template

163

171template

174

182template

185

193template

196

204template

207

215template

218

226template

229

237template

238auto

239host_begin(C& host_container) -> decltype(host_container.host_begin());

240

248template

249auto

250host_end(C& host_container) -> decltype(host_container.host_end());

251

259template

260auto

261device_begin(C& device_container) -> decltype(device_container.device_begin());

262

270template

271auto

272device_end(C& device_container) -> decltype(device_container.device_end());

273

281template

282auto

283host_begin(const C& host_container) -> decltype(host_container.host_begin());

284

292template

293auto

294host_end(const C& host_container) -> decltype(host_container.host_end());

295

303template

304auto

305device_begin(const C& device_container) -> decltype(device_container.device_begin());

306

314template

315auto

316device_end(const C& device_container) -> decltype(device_container.device_end());

317

325template

326auto

328

336template

337auto

339

347template

348auto

350

358template

359auto

361

362namespace detail

363{

364

365template

366struct back_insert_iterator_base;

367

368template

369struct front_insert_iterator_base;

370

371template

372struct insert_iterator_base;

373

374}

375

381template

383{

384public:

388 using super_t = typename detail::back_insert_iterator_base::type;

389

390 friend class thrust::iterator_core_access;

392

399

400private:

402 dereference() const;

403

404 Container _c;

405};

406

413template

416

422template

424{

425public:

429 using super_t = typename detail::front_insert_iterator_base::type;

430

431 friend class thrust::iterator_core_access;

433

440

441private:

443 dereference() const;

444

445 Container _c;

446};

447

454template

457

466template

467class insert_iterator : public detail::insert_iterator_base::type

468{

469public:

473 using super_t = typename detail::insert_iterator_base::type;

474

475 friend class thrust::iterator_core_access;

477

484

485private:

487 dereference() const;

488

489 Container _c;

490};

491

498template

501

502}

503

504#include <stdgpu/impl/iterator_detail.h>

505

506#endif

STDGPU_HOST_DEVICE back_insert_iterator(Container &c)

Constructor.

Container container_type

Definition: iterator.h:385

An output iterator which inserts elements into a container using push_back.

Definition: iterator.h:383

Container container_type

Definition: iterator.h:426

STDGPU_HOST_DEVICE front_insert_iterator(Container &c)

Constructor.

An output iterator which inserts elements into a container using push_front.

Definition: iterator.h:424

STDGPU_HOST_DEVICE insert_iterator(Container &c)

Constructor.

Container container_type

Definition: iterator.h:470

An output iterator which inserts elements into a container using insert.

Definition: iterator.h:468

std::ptrdiff_t index64_t

std::ptrdiff_t

Definition: cstddef.h:48

STDGPU_HOST_DEVICE insert_iterator< Container > inserter(Container &c)

Constructs an insert_iterator.

thrust::pointer< T, thrust::device_system_tag > device_ptr

A host pointer class allowing to call thrust algorithms without explicitly using the respective execu...

Definition: iterator.h:43

host_ptr< const T > host_cend(const T *host_array)

Creates a constant pointer to the end of the given host array.

host_ptr< T > host_begin(T *host_array)

Creates a pointer to the begin of the given host array.

device_ptr< const T > device_cbegin(const T *device_array)

Creates a constant pointer to the begin of the given device array.

device_ptr< const T > device_cend(const T *device_array)

Creates a constant pointer to the end of the given device array.

host_ptr< const T > host_cbegin(const T *host_array)

Creates a constant pointer to the begin of the given host array.

STDGPU_HOST_DEVICE back_insert_iterator< Container > back_inserter(Container &c)

Constructs a back_insert_iterator.

device_ptr< T > device_begin(T *device_array)

Creates a pointer to the begin of the given device array.

STDGPU_HOST_DEVICE device_ptr< T > make_device(T *device_array)

Constructs a device_ptr object.

device_ptr< T > device_end(T *device_array)

Creates a pointer to the end of the given device array.

STDGPU_HOST_DEVICE host_ptr< T > make_host(T *host_array)

Constructs a host_ptr object.

index64_t size(T *array)

Finds the size (number of elements) of the given dynamically allocated array.

host_ptr< T > host_end(T *host_array)

Creates a pointer to the end of the given host array.

STDGPU_HOST_DEVICE front_insert_iterator< Container > front_inserter(Container &c)

Constructs a front_insert_iterator.

thrust::pointer< T, thrust::host_system_tag > host_ptr

A host pointer class allowing to call thrust algorithms without explicitly using the respective execu...

Definition: iterator.h:51

#define STDGPU_HOST_DEVICE

Platform-independent host device function annotation.

Definition: platform.h:77