File tree Expand file tree Collapse file tree 2 files changed +24
-29
lines changed
Expand file tree Collapse file tree 2 files changed +24
-29
lines changed Original file line number Diff line number Diff line change 1717
1818#ifndef Rcpp_protection_meat_H
1919#define Rcpp_protection_meat_H
20-
20+
2121namespace Rcpp {
2222
2323 template <typename T>
2424 template <typename U>
2525 Armor<T>::Armor( U x ) : data() {
2626 init ( wrap (x) ) ;
27- }
28-
27+ }
28+
2929 template <typename T>
3030 template <typename U>
3131 inline Armor<T>& Armor<T>::operator =( const U& x ){
3232 REPROTECT (data = wrap (x), index) ;
3333 return *this ;
3434 }
35-
36- template <typename T>
37- template <typename U>
38- inline Shield<T>::operator U () const {
39- return as<U>(t) ;
40- }
35+
4136}
4237
4338#endif
Original file line number Diff line number Diff line change 1- // Copyright (C) 2013 Romain Francois
1+ // Copyright (C) 2013 Romain Francois and Kevin Ushey
22//
33// This file is part of Rcpp.
44//
1515// You should have received a copy of the GNU General Public License
1616// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1717
18- #ifndef Rcpp_protection_Shield_H
19- #define Rcpp_protection_Shield_H
18+ #ifndef Rcpp__protection_Shield_h
19+ #define Rcpp__protection_Shield_h
20+
21+ namespace Rcpp {
22+
23+ inline SEXP Rcpp_protect (SEXP x){
24+ if ( x != R_NilValue ) PROTECT (x) ;
25+ return x ;
26+ }
2027
21- namespace Rcpp {
22-
2328 template <typename T>
2429 class Shield {
2530 public:
26- Shield ( SEXP t_) : t(PROTECT (t_)){}
31+ Shield ( SEXP t_) : t(Rcpp_protect (t_)){}
2732 ~Shield (){
28- UNPROTECT (1 ) ;
29- }
30-
31- template <typename U>
32- inline operator U () const ;
33-
34- inline operator SEXP () const {
35- return t ;
33+ if ( t != R_NilValue ) UNPROTECT (1 ) ;
3634 }
37-
38- private:
39- // not defined on purpose
35+
36+ operator SEXP () const { return t; }
37+ SEXP t ;
38+
39+ private:
4040 Shield ( const Shield& ) ;
4141 Shield& operator =( const Shield& ) ;
42-
43- SEXP t ;
4442 } ;
45-
43+
44+
45+
4646}
4747
4848#endif
You can’t perform that action at this time.
0 commit comments