Skip to content

Commit 579cb41

Browse files
committed
If C++11 support is detected during Rcpp compilation, report it via Rcpp::capabilities()[["Full C++11 support"]] and Rcpp::rcpp_can_use_cxx11()
1 parent 9511768 commit 579cb41

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/Rcpp_init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static R_CallMethodDef callEntries[] = {
5656

5757
CALLDEF(rcpp_capabilities,0),
5858
CALLDEF(rcpp_can_use_cxx0x,0),
59+
CALLDEF(rcpp_can_use_cxx11,0),
5960
{NULL, NULL, 0}
6061
};
6162

src/api.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ SEXP as_character_externalptr(SEXP xp){
155155

156156
// [[Rcpp::internal]]
157157
SEXP rcpp_capabilities(){
158-
Shield<SEXP> cap( Rf_allocVector( LGLSXP, 11 ) );
159-
Shield<SEXP> names( Rf_allocVector( STRSXP, 11 ) );
158+
Shield<SEXP> cap( Rf_allocVector( LGLSXP, 12 ) );
159+
Shield<SEXP> names( Rf_allocVector( STRSXP, 12 ) );
160160
#ifdef HAS_VARIADIC_TEMPLATES
161161
LOGICAL(cap)[0] = TRUE ;
162162
#else
@@ -210,6 +210,12 @@ SEXP rcpp_capabilities(){
210210
LOGICAL(cap)[10] = FALSE ;
211211
#endif
212212

213+
#ifdef RCPP_USING_CXX11
214+
LOGICAL(cap)[11] = TRUE ;
215+
#else
216+
LOGICAL(cap)[11] = FALSE ;
217+
#endif
218+
213219
SET_STRING_ELT(names, 0, Rf_mkChar("variadic templates") ) ;
214220
SET_STRING_ELT(names, 1, Rf_mkChar("initializer lists") ) ;
215221
SET_STRING_ELT(names, 2, Rf_mkChar("exception handling") ) ;
@@ -221,14 +227,25 @@ SEXP rcpp_capabilities(){
221227
SET_STRING_ELT(names, 8, Rf_mkChar("long long") ) ;
222228
SET_STRING_ELT(names, 9, Rf_mkChar("C++0x unordered maps") ) ;
223229
SET_STRING_ELT(names, 10, Rf_mkChar("C++0x unordered sets") ) ;
230+
SET_STRING_ELT(names, 11, Rf_mkChar("Full C++11 support") ) ;
224231
Rf_setAttrib( cap, R_NamesSymbol, names ) ;
225232
return cap ;
226233
}
227234

228235

229236
// [[Rcpp::internal]]
230237
SEXP rcpp_can_use_cxx0x(){
231-
#ifdef HAS_VARIADIC_TEMPLATES
238+
#if defined(HAS_VARIADIC_TEMPLATES) || defined(RCPP_USING_CXX11)
239+
return Rf_ScalarLogical( TRUE );
240+
#else
241+
return Rf_ScalarLogical( FALSE );
242+
#endif
243+
}
244+
245+
246+
// [[Rcpp::internal]]
247+
SEXP rcpp_can_use_cxx11(){
248+
#if defined(RCPP_USING_CXX11)
232249
return Rf_ScalarLogical( TRUE );
233250
#else
234251
return Rf_ScalarLogical( FALSE );

src/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ CALLFUN_4(CppField__set);
120120

121121
CALLFUN_0(rcpp_capabilities) ;
122122
CALLFUN_0(rcpp_can_use_cxx0x) ;
123+
CALLFUN_0(rcpp_can_use_cxx11) ;
123124

124125
/* .External functions */
125126
EXTFUN(CppMethod__invoke) ;

0 commit comments

Comments
 (0)