Skip to content

Commit 619ecf2

Browse files
as<char> specialization
1 parent 430e88a commit 619ecf2

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
* R/Attributes.R: Don't search the inline package as a fallback when loading plugins for the the Rcpp::plugins attribute
44

5-
2013-09-16 Romain Francois <romain@r-enthusiasts.com>
5+
2013-09-18 Romain Francois <romain@r-enthusiasts.com>
66

77
* vignettes/Rcpp-package.Rnw: Updating the vignette. Setting attributes to TRUE
88
by default.
99
* R/Rcpp.package.skeleton.R: Setting attributes to TRUE by default. This is
1010
what we should encourage people to use.
11+
* include/Rcpp/as.h: add as<char> specialization
1112

1213
2013-09-17 JJ Allaire <jj@rstudio.org>
1314

TODO

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ Current active misfeatures
1010
o DataFrame::create(Named("a")=b, Named("b")=b) fails with
1111
NumericVectors
1212

13-
o Single char variables do not seem to covered correctly by as<>()
14-
and wrap() (cf http://stackoverflow.com/questions/16535899/)
15-
1613
Documentation
1714

1815
o Finish the quickref vignette

inst/include/Rcpp/as.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ namespace Rcpp{
145145
return internal::as<T>( m_sexp, typename traits::r_type_traits<T>::r_category() ) ;
146146
}
147147

148+
template <> inline char as<char>( SEXP m_sexp ){
149+
return internal::check_single_string(m_sexp)[0] ;
150+
}
151+
148152
template <typename T>
149153
inline typename traits::remove_const_and_reference<T>::type bare_as( SEXP m_sexp ){
150154
return as< typename traits::remove_const_and_reference<T>::type >( m_sexp ) ;

0 commit comments

Comments
 (0)