Skip to content

Commit 62d94db

Browse files
committed
Wrap dispatch for character arrays
1 parent e53b122 commit 62d94db

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

inst/include/Rcpp/internal/wrap.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,11 @@ inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_primitive_
744744
return primitive_wrap( object ) ;
745745
}
746746

747+
template <typename T>
748+
inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_char_array ) {
749+
return Rf_mkString(object);
750+
}
751+
747752
template <typename T>
748753
inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_module_object_pointer_tag ){
749754
return Rcpp::internal::make_new_object< typename T::object_type >( object.ptr ) ;

inst/include/Rcpp/traits/wrap_type_traits.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ struct wrap_type_module_object_tag{} ;
5151
*/
5252
struct wrap_type_enum_tag{} ;
5353

54+
/**
55+
* character arrays
56+
*/
57+
struct wrap_type_char_array{} ;
58+
5459
/**
5560
* Type trait that helps the dispatch of wrap to the proper method
5661
*
@@ -62,6 +67,8 @@ struct wrap_type_enum_tag{} ;
6267
*/
6368
template <typename T> struct wrap_type_traits { typedef wrap_type_unknown_tag wrap_category; } ;
6469

70+
template <std::size_t N> struct wrap_type_traits<char[N]> { typedef wrap_type_char_array wrap_category; } ;
71+
template <std::size_t N> struct wrap_type_traits<const char[N]> { typedef wrap_type_char_array wrap_category; } ;
6572
/**
6673
* Total specialization for primitive types
6774
*/

0 commit comments

Comments
 (0)