Rcpp Version 1.0.14
Loading...
Searching...
No Matches
has_iterator.h
Go to the documentation of this file.
1
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
3
//
4
// has_iterator.h: Rcpp R/C++ interface class library -- identify if a class has a nested iterator typedef
5
//
6
// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
7
//
8
// This file is part of Rcpp.
9
//
10
// Rcpp is free software: you can redistribute it and/or modify it
11
// under the terms of the GNU General Public License as published by
12
// the Free Software Foundation, either version 2 of the License, or
13
// (at your option) any later version.
14
//
15
// Rcpp is distributed in the hope that it will be useful, but
16
// WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU General Public License for more details.
19
//
20
// You should have received a copy of the GNU General Public License
21
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
22
23
#ifndef Rcpp__traits__has_iterator__h
24
#define Rcpp__traits__has_iterator__h
25
26
/* "inspired" from the tr1_impl/functional file
27
This uses the SFINAE technique to identify if a class T has
28
an iterator typedef
29
*/
30
31
namespace
Rcpp
{
32
namespace
traits{
33
34
struct
__sfinae_types
{
35
typedef
char
__one
;
36
typedef
struct
{
char
__arr[2]; }
__two
;
37
};
38
39
template
<
typename
T>
40
class
_has_iterator_helper
:
__sfinae_types
{
41
template
<
typename
U>
struct
_Wrap_type
{ };
42
43
template
<
typename
U>
44
static
__one
__test
(
_Wrap_type<typename U::iterator>
*);
45
46
template
<
typename
U>
47
static
__two
__test
(...);
48
49
public
:
50
static
const
bool
value
=
sizeof
(
__test<T>
(0)) == 1;
51
};
52
53
template
<
typename
T>
54
class
_is_importer_helper
:
__sfinae_types
{
55
template
<
typename
U>
struct
_Wrap_type
{ };
56
57
template
<
typename
U>
58
static
__one
__test
(
_Wrap_type<typename U::r_import_type>
*);
59
60
template
<
typename
U>
61
static
__two
__test
(...);
62
63
public
:
64
static
const
bool
value
=
sizeof
(
__test<T>
(0)) == 1;
65
};
66
67
template
<
typename
T>
68
class
_is_generator_helper
:
__sfinae_types
{
69
template
<
typename
U>
struct
_Wrap_type
{ };
70
71
template
<
typename
U>
72
static
__one
__test
(
_Wrap_type<typename U::r_generator>
*);
73
74
template
<
typename
U>
75
static
__two
__test
(...);
76
77
public
:
78
static
const
bool
value
=
sizeof
(
__test<T>
(0)) == 1;
79
};
80
81
82
template
<
typename
T>
83
class
_is_exporter_helper
:
__sfinae_types
{
84
template
<
typename
U>
struct
_Wrap_type
{ };
85
86
template
<
typename
U>
87
static
__one
__test
(
_Wrap_type<typename U::r_export_type>
*);
88
89
template
<
typename
U>
90
static
__two
__test
(...);
91
92
public
:
93
static
const
bool
value
=
sizeof
(
__test<T>
(0)) == 1;
94
};
95
103
template
<
typename
T>
struct
has_iterator
:
104
integral_constant
<bool,_has_iterator_helper<T>::value> { };
105
112
template
<
typename
T>
struct
is_importer
:
113
integral_constant
<bool,_is_importer_helper<T>::value> { };
114
115
template
<
typename
T>
struct
is_exporter
:
116
integral_constant
<bool,_is_exporter_helper<T>::value> { };
117
118
template
<
typename
T>
struct
is_generator
:
119
integral_constant
<bool,_is_generator_helper<T>::value> { };
120
121
}
// traits
122
}
// Rcpp
123
124
#endif
Rcpp::traits::_has_iterator_helper
Definition
has_iterator.h:40
Rcpp::traits::_has_iterator_helper::__test
static __one __test(_Wrap_type< typename U::iterator > *)
Rcpp::traits::_has_iterator_helper::__test
static __two __test(...)
Rcpp::traits::_has_iterator_helper::value
static const bool value
Definition
has_iterator.h:50
Rcpp::traits::_is_exporter_helper
Definition
has_iterator.h:83
Rcpp::traits::_is_exporter_helper::__test
static __one __test(_Wrap_type< typename U::r_export_type > *)
Rcpp::traits::_is_exporter_helper::value
static const bool value
Definition
has_iterator.h:93
Rcpp::traits::_is_exporter_helper::__test
static __two __test(...)
Rcpp::traits::_is_generator_helper
Definition
has_iterator.h:68
Rcpp::traits::_is_generator_helper::value
static const bool value
Definition
has_iterator.h:78
Rcpp::traits::_is_generator_helper::__test
static __two __test(...)
Rcpp::traits::_is_generator_helper::__test
static __one __test(_Wrap_type< typename U::r_generator > *)
Rcpp::traits::_is_importer_helper
Definition
has_iterator.h:54
Rcpp::traits::_is_importer_helper::value
static const bool value
Definition
has_iterator.h:64
Rcpp::traits::_is_importer_helper::__test
static __one __test(_Wrap_type< typename U::r_import_type > *)
Rcpp::traits::_is_importer_helper::__test
static __two __test(...)
Rcpp
Rcpp API.
Definition
algo.h:28
Rcpp::as
T as(SEXP x)
Definition
as.h:151
Rcpp::traits::__sfinae_types::__two
Definition
has_iterator.h:36
Rcpp::traits::__sfinae_types
Definition
has_iterator.h:34
Rcpp::traits::__sfinae_types::__one
char __one
Definition
has_iterator.h:35
Rcpp::traits::_has_iterator_helper::_Wrap_type
Definition
has_iterator.h:41
Rcpp::traits::_is_exporter_helper::_Wrap_type
Definition
has_iterator.h:84
Rcpp::traits::_is_generator_helper::_Wrap_type
Definition
has_iterator.h:69
Rcpp::traits::_is_importer_helper::_Wrap_type
Definition
has_iterator.h:55
Rcpp::traits::has_iterator
Definition
has_iterator.h:104
Rcpp::traits::integral_constant
Definition
integral_constant.h:29
Rcpp::traits::is_exporter
Definition
has_iterator.h:116
Rcpp::traits::is_generator
Definition
has_iterator.h:119
Rcpp::traits::is_importer
Definition
has_iterator.h:113
inst
include
Rcpp
traits
has_iterator.h
Generated on Sun Jan 12 2025 11:21:43 for Rcpp Version 1.0.14 by
1.9.8