Skip to content

Commit 9704ae9

Browse files
fix String compiler ambiguity. should fix #59
1 parent df9f81e commit 9704ae9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

inst/include/Rcpp/String.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace Rcpp {
5151
class String {
5252
public:
5353
typedef internal::string_proxy<STRSXP> StringProxy;
54+
typedef internal::const_string_proxy<STRSXP> const_StringProxy;
5455

5556
/** default constructor */
5657
String( ): data( Rf_mkChar("") ), buffer(), valid(true), buffer_ready(true) {
@@ -71,6 +72,10 @@ namespace Rcpp {
7172
String( const StringProxy& proxy ): data( proxy.get() ), valid(true), buffer_ready(false){
7273
RCPP_STRING_DEBUG( "String( const StringProxy&)" ) ;
7374
}
75+
/** from string proxy */
76+
String( const const_StringProxy& proxy ): data( proxy.get() ), valid(true), buffer_ready(false){
77+
RCPP_STRING_DEBUG( "String( const const_StringProxy&)" ) ;
78+
}
7479

7580
/** from a std::string */
7681
String( const std::string& s) : buffer(s), valid(false), buffer_ready(true) {
@@ -250,6 +255,12 @@ namespace Rcpp {
250255
valid = false ;
251256
return *this ;
252257
}
258+
259+
template <typename LHS, typename RHS>
260+
inline String& replace_all( const LHS& s, const RHS& news ){
261+
return replace_all( String( s ), String(news) ) ;
262+
}
263+
253264
inline String& replace_all( const Rcpp::String& s, const char* news ){
254265
// replace NA -> do nothing
255266
if( s.is_na() ) return *this ;

inst/unitTests/cpp/String.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ List test_compare_Strings( String aa, String bb ){
5353
_["a > b" ] = aa > bb,
5454
_["a == b"] = aa == bb,
5555
_["a == a"] = aa == aa
56-
5756
) ;
5857
}
5958

0 commit comments

Comments
 (0)