Skip to content

Commit c35c8f4

Browse files
committed
Add 'const' case to complement 'plain', 'reference' and 'const reference'
1 parent 8e8c781 commit c35c8f4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
2013-09-15 Dirk Eddelbuettel <edd@debian.org>
22

3+
* inst/include/Rcpp/InputParameter.h (Rcpp): Add 'const' case
4+
35
* inst/unitTests/cpp/Vector.cpp: New unit tests for std::vector
46
conversions, using both int and double arguments
57
* inst/unitTests/runit.Vector.R: R complement of these tests

inst/include/Rcpp/InputParameter.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ namespace Rcpp {
5050
private:
5151
T obj ;
5252
} ;
53+
54+
// same for const
55+
template <typename T>
56+
class ConstInputParameter {
57+
public:
58+
typedef const T const_nonref ;
59+
ConstInputParameter(SEXP x_) : obj( as<T>(x_) ){}
60+
61+
inline operator const_nonref() { return obj ; }
62+
63+
private:
64+
T obj ;
65+
} ;
5366

5467
// same for const references
5568
template <typename T>
@@ -74,6 +87,10 @@ namespace Rcpp {
7487
typedef typename Rcpp::ReferenceInputParameter<T> type ;
7588
} ;
7689
template <typename T>
90+
struct input_parameter<const T> {
91+
typedef typename Rcpp::ConstInputParameter<T> type ;
92+
} ;
93+
template <typename T>
7794
struct input_parameter<const T&> {
7895
typedef typename Rcpp::ConstReferenceInputParameter<T> type ;
7996
} ;

0 commit comments

Comments
 (0)