Skip to content

Commit b58eb29

Browse files
trying out a different approach (declarative) for presence of copy construcror
1 parent 502481e commit b58eb29

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

inst/include/Rcpp/traits/has_copy_constructor.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,12 @@
2323
namespace Rcpp{
2424
namespace traits{
2525

26-
template<typename T>
27-
class _has_copy_constructor_helper : __sfinae_types {
28-
template<typename U> struct _Wrap_type { };
29-
30-
template<typename U>
31-
static __one __test(U);
32-
33-
template<typename U>
34-
static __two __test(...);
35-
36-
public:
37-
static const bool value = sizeof(__test<T>(0)) == 1;
38-
};
39-
40-
template<typename T> struct has_copy_constructor :
41-
integral_constant<bool,_has_copy_constructor_helper<T>::value> { };
26+
#if defined(RCPP_USING_CXX11)
27+
template <typename T> struct has_copy_constructor :
28+
integral_constant<bool, std::is_copy_constructible<T>::value >{} ;
29+
#else
30+
template<typename T> struct has_copy_constructor : true_type ;
31+
#endif
4232

4333
} // traits
4434
} // Rcpp

inst/unitTests/cpp/Module.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ class ModuleCopyConstructor {
119119
} ;
120120

121121
RCPP_EXPOSED_CLASS(ModuleTest)
122+
123+
namespace Rcpp {
124+
namespace traits {
125+
template <> struct has_copy_constructor<ModuleTest> : false_type ;
126+
}
127+
}
128+
122129
class ModuleTest {
123130
public:
124131
double value;

0 commit comments

Comments
 (0)