22//
33// const_string_proxy.h: Rcpp R/C++ interface class library --
44//
5- // Copyright (C) 2013 Romain Francois
5+ // Copyright (C) 2013 - 2018 Romain Francois
66//
77// This file is part of Rcpp.
88//
2525namespace Rcpp {
2626namespace internal {
2727
28- template <int RTYPE> class const_string_proxy {
28+ template <int RTYPE, template <class > class StoragePolicy >
29+ class const_string_proxy {
2930 public:
3031
31- typedef typename ::Rcpp::Vector<RTYPE> VECTOR ;
32+ typedef typename ::Rcpp::Vector<RTYPE, StoragePolicy > VECTOR ;
3233 typedef const char * iterator ;
3334 typedef const char & reference ;
3435
@@ -43,7 +44,7 @@ namespace internal{
4344 const_string_proxy ( const VECTOR& v, R_xlen_t index_ ) : parent(&v), index(index_){}
4445
4546 const_string_proxy (SEXP x): parent(0 ), index(0 ) {
46- Vector<RTYPE> tmp (x);
47+ VECTOR tmp (x);
4748 parent = &tmp;
4849 }
4950
@@ -76,11 +77,11 @@ namespace internal{
7677 * Prints the element this proxy refers to to an
7778 * output stream
7879 */
79- template <int RT>
80- friend std::ostream& operator <<(std::ostream& os, const const_string_proxy<RT>& proxy);
80+ template <int RT, template < class > class StoragePolicy_ >
81+ friend std::ostream& operator <<(std::ostream& os, const const_string_proxy<RT, StoragePolicy_ >& proxy);
8182
82- template <int RT>
83- friend std::string operator +( const std::string& x, const const_string_proxy<RT>& proxy);
83+ template <int RT, template < class > class StoragePolicy_ >
84+ friend std::string operator +( const std::string& x, const const_string_proxy<RT, StoragePolicy_ >& proxy);
8485
8586 const VECTOR* parent;
8687 R_xlen_t index ;
@@ -110,13 +111,13 @@ namespace internal{
110111 return strcmp ( begin (), other.begin () ) != 0 ;
111112 }
112113
113- bool operator ==( SEXP other ) const {
114- return get () == other;
115- }
114+ bool operator ==( SEXP other ) const {
115+ return get () == other;
116+ }
116117
117- bool operator !=( SEXP other ) const {
118- return get () != other;
119- }
118+ bool operator !=( SEXP other ) const {
119+ return get () != other;
120+ }
120121
121122 private:
122123 static std::string buffer ;
@@ -155,20 +156,22 @@ namespace internal{
155156 ) <= 0 ;
156157 }
157158
158- template <int RTYPE> std::string const_string_proxy<RTYPE>::buffer ;
159+ template <int RTYPE, template < class > class StoragePolicy > std::string const_string_proxy<RTYPE, StoragePolicy >::buffer ;
159160
160- inline std::ostream& operator <<(std::ostream& os, const const_string_proxy<STRSXP>& proxy) {
161+ template <template <class > class StoragePolicy >
162+ inline std::ostream& operator <<(std::ostream& os, const const_string_proxy<STRSXP, StoragePolicy>& proxy) {
161163 os << static_cast <const char *>(proxy) ;
162164 return os;
163165 }
164166
165- inline std::string operator +( const std::string& x, const const_string_proxy<STRSXP>& y ){
167+ template <template <class > class StoragePolicy >
168+ inline std::string operator +( const std::string& x, const const_string_proxy<STRSXP, StoragePolicy>& y ){
166169 return x + static_cast <const char *>(y) ;
167170 }
168171
169-
170- template <int RTYPE >
171- string_proxy<RTYPE>& string_proxy<RTYPE>::operator =(const const_string_proxy<RTYPE>& other){
172+ template < int RTYPE, template < class > class StoragePolicy1 >
173+ template <template < class > class StoragePolicy2 >
174+ string_proxy<RTYPE, StoragePolicy1 >& string_proxy<RTYPE, StoragePolicy1 >::operator =(const const_string_proxy<RTYPE, StoragePolicy2 >& other){
172175 set ( other.get () ) ;
173176 return *this ;
174177 }
0 commit comments