-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathWeakReference.h
More file actions
43 lines (33 loc) · 877 Bytes
/
WeakReference.h
File metadata and controls
43 lines (33 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef Rcpp_WeakReference_h
#define Rcpp_WeakReference_h
namespace Rcpp{
RCPP_API_CLASS(WeakReference_Impl) {
public:
RCPP_GENERATE_CTOR_ASSIGN(WeakReference_Impl)
/**
* wraps a weak reference
*
* @param x presumably a SEXP of SEXTYPE WEAKREFSXP
*
* @throw not_compatible if x is not a weak reference
*/
WeakReference_Impl( SEXP x){
if( TYPEOF(x) != WEAKREFSXP )
throw not_compatible( "not a weak reference" ) ;
Storage::set__(x) ;
}
/**
* Retrieve the key
*/
SEXP key() {
return R_WeakRefKey(Storage::get__()) ;
}
/**
* Retrieve the value
*/
SEXP value(){
return R_WeakRefValue(Storage::get__());
}
} ;
}
#endif