I get the below output. I'm still learning C++, so I'm not 100% sure if this is intended behavior, but I think not.
> cpp11::cpp_register()
> devtools::document()
Updating testcpp11 documentation
Loading testcpp11
Re-compiling testcpp11
─ installing *source* package ‘testcpp11’ ...
** using staged installation
** libs
ccache g++-10 -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I"/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include" -fpic -g -O2 -fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c helloCpp.cpp -o helloCpp.o
helloCpp.cpp: In function ‘SEXPREC* table_cpp(cpp11::doubles)’:
helloCpp.cpp:74:24: error: no matching function for call to ‘as_sexp(std::map<double, int>&)’
74 | return as_sexp(counts);
| ^
In file included from /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11.hpp:5,
from helloCpp.cpp:2:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:144:13: note: candidate: ‘template<class T, cpp11::is_integral<T>* <anonymous> > SEXPREC* cpp11::as_sexp(T)’
144 | inline SEXP as_sexp(T from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:144:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp: In substitution of ‘template<class T> using is_integral = typename std::enable_if<((std::is_integral<_Tp>::value && (! std::is_same<typename std::decay<_Tp>::type, bool>::value)) && (! std::is_same<typename std::decay<_Tp>::type, char>::value)), typename std::decay<_Tp>::type>::type [with T = std::map<double, int>]’:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:143:41: required from here
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:25:7: error: no type named ‘type’ in ‘struct std::enable_if<false, std::map<double, int> >’
25 | using is_integral = typename std::enable_if<
| ^~~~~~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:149:13: note: candidate: ‘template<class T, cpp11::is_floating_point_value<T>* <anonymous> > SEXPREC* cpp11::as_sexp(T)’
149 | inline SEXP as_sexp(T from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:149:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp: In subs /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp: In substitution of ‘template<class T> using is_floating_point_value = typename std::enable_if<std::is_floating_point<_Tp>::value, T>::type [with T = std::map<double, int>]’:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:148:53: required from here
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:83:7: error: no type named ‘type’ in ‘struct std::enable_if<false, std::map<double, int> >’
83 | using is_floating_point_value =
| ^~~~~~~~~~~~~~~~~~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:153:13: note: candidate: ‘SEXPREC* cpp11::as_sexp(const string&)’
153 | inline SEXP as_sexp(const std::string& from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:153:40: note: no known conversion for argument 1 from ‘std::map<double, int>’ to ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’}
153 | inline SEXP as_sexp(const std::string& from) {
| ~~~~~~~~~~~~~~~~~~~^~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:165:13: note: candidate: ‘template<class T, typename std::enable_if<std::is_same<typename std::decay<_Tp>::type, bool>::value, typename std::decay<_Tp>::type>::type <anonymous> > SEXPREC* cpp11::as_sexp(T)’
165 | inline SEXP as_sexp(T from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:165:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:164:36: error: no type named ‘type’ in ‘struct std::enable_if<false, std::map<double, int> >’
164 | template <typename T, is_bool<T> = false>
| ^~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:172:13: note: candidate: ‘template<class C, class T, typename std::enable_if<(! std::is_convertible<C, SEXPREC*>::value), typename std::enable_if<((std::is_integral<_Si /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:172:13: note: candidate: ‘template<class C, class T, typename std::enable_if<(! std::is_convertible<C, SEXPREC*>::value), typename std::enable_if<((std::is_integral<_Size>::value && (! std::is_same<typename std::decay<_Tp2>::type, bool>::value)) && (! std::is_same<typename std::decay<_Tp2>::type, char>::value)), typename std::decay<_Tp2>::type>::type>::type* <anonymous> > SEXPREC* cpp11::as_sexp(C)’
172 | inline SEXP as_sexp(C from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:172:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:171:60: error: no type named ‘type’ in ‘struct std::enable_if<false, std::pair<const double, int> >’
171 | is_integral<T>>::type* = nullptr>
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:184:13: note: candidate: ‘SEXPREC* cpp11::as_sexp(std::initializer_list<int>)’
184 | inline SEXP as_sexp(std::initializer_list<int> from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:184:48: note: no known conversion for argument 1 from ‘std::map<double, int>’ to ‘std::initializer_list<int>’
184 | inline SEXP as_sexp(std::initializer_list<int> from) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:190:13: note: candidate: ‘template<class C, class T, cpp11::is_floating_point_value<T>* <anonymous> > SEXPREC* cpp11::as_sexp(C)’
190 | inline SEXP as_sexp(C from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:190:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp: In substitution of ‘template<class T> using is_floating_point_value = typename std::enable_if<std::is_floating_point<_Tp>::value, T>::type [with T = std::pair<const double, int>]’:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:189:41: required from here
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:83:7: error: no type named ‘type’ in ‘struct std::enable_if<false, std::pair<const double, int> >’
83 | using is_floating_point_value =
| ^~~~~~~~~~~~~~~~~~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:202:13: note: candidate: ‘SEXPREC* cpp11::as_sexp(std::initializer_list<double>)’
202 | inline SEXP as_sexp(std::initializer_list<double> from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:202:51: note: no known conversion for argument 1 from ‘std::map<double, int>’ to ‘std::initializer_list<double>’
202 | inline SEXP as_sexp(std::initializer_list<double> from) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:207:13: note: candidate: ‘template<class C, class T, cpp11::is_bool<T>* <anonymous> > SEXPREC* cpp11::as_sexp(C)’
207 | inline SEXP as_sexp(C from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:207:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp: In substitution of ‘template<class T> using is_bool = typename std::enable_if<std::is_same<typename std::decay<_Tp>::type, bool>::value, typename std::decay<_Tp>::type>::type [with T = std::pair<const double, int>]’:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:206:74: required from here
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:160:7: error: no type named ‘type’ in ‘struct std::enable_if<false, std::pair<const double, int> >’
160 | using is_bool =
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:219:13: /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:219:13: note: candidate: ‘SEXPREC* cpp11::as_sexp(std::initializer_list<bool>)’
219 | inline SEXP as_sexp(std::initializer_list<bool> from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:219:49: note: no known conversion for argument 1 from ‘std::map<double, int>’ to ‘std::initializer_list<bool>’
219 | inline SEXP as_sexp(std::initializer_list<bool> from) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:231:13: note: candidate: ‘template<class C, class T, cpp11::is_convertible_to_std_string<T>* <anonymous> > SEXPREC* cpp11::as_sexp(C)’
231 | inline SEXP as_sexp(C from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:231:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp: In substitution of ‘template<class T> using is_convertible_to_std_string = typename std::enable_if<(std::is_convertible<typename std::decay<_Tp>::type, std::__cxx11::basic_string<char> >::value && (! std::is_convertible<typename std::decay<_Tp>::type, const char*>::value)), typename std::decay<_Tp>::type>::type [with T = std::pair<const double, int>]’:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:230:46: required from here
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:224:7: error: no type named ‘type’ in ‘struct std::enable_if<false, std::pair<const double, int> >’
224 | using is_convertible_to_std_string = typename std::enable_if<
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:259:13: note: candidate: ‘template<class C, class T, cpp11::is_convertible_to_const_char<T>* <anonymous> > SEXPREC* cpp11::as_sexp(C)’
259 | inline SEXP as_sexp(C from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:259:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp: In substitution of ‘template<class T> using is_convertible_to_const_char = typename std::enable_if<(std::is_convertible<typename std::decay<_Tp>::type, const char*>::value && (! std::is_convertible<typename std::decay<_Tp>::type, SEXPREC*>::value)), typename std::decay<_Tp>::type>::type [with T = std::pair<const double, int>]’:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:258:46: required from here
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:252:7: error: no type named ‘type’ in ‘struct std::enable_if<false, std::pair<const double, int> >’
252 | using is_convertible_to_const_char = typename std::enable_if<
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:279:13: note: candidate: ‘SEXPREC* cpp11::as_sexp(std::initializer_list<const char*>)’
279 | inline SEXP as_sexp(std::initializer_list<const char*> from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:279:56: note: no known conversion for argument 1 from ‘std::map<double, int>’ to ‘std::initializer_list<const char*>’
279 | inline SEXP as_sexp(std::initializer_list<const char*> from) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:283:13: note: candidate: ‘SEXPREC* cpp11::as_sexp(SEXP)’
283 | inline SEXP as_sexp(SEXP from) { return from; }
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/as.hpp:283:26: note: no known conversion for argument 1 from ‘std::map<double, int>’ to ‘SEXP’ {aka ‘SEXPREC*’}
283 | inline SEXP as_sexp(SEXP from) { return from; }
| ~~~~~^~~~
In file included from /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/list.hpp:8,
from /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/data_frame.hpp:10,
from /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11.hpp:7,
from helloCpp.cpp:2:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp:58:13: note: candidate: ‘template<class T, cpp11::is_convertible_to_cpp11_string<T>* <anonymous> > SEXPREC* cpp11::as_sexp(T)’
58 | inline SEXP as_sexp(T from) {
| ^~~~~~~
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp:58:13: note: template argument deduction/substitution failed:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp: In substitution of ‘template<class T> using is_convertible_to_cpp11_string = typename std::enable_if<(std::is_convertible<T, cpp11::r_string>::value && (! std::is_convertible<T, const char*>::value)), T>::type [with T = std::map<double, int>]’:
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp:57:60: required from here
/home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp:52:7: error: no type named ‘type’ in ‘struct std::enable_if<false, std::map<double, int> >’
52 | using is_convertible_to_cpp11_string =
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/R/etc/Makeconf:177: recipe for target 'helloCpp.o' failed
make: *** [helloCpp.o] Error 1
ERROR: compilation failed for package ‘testcpp11’
─ removing ‘/tmp/Rtmp6dP72C/devtools_install_1f3d6b99a0e5/testcpp11’
Error in (function (command = NULL, args = character(), error_on_status = TRUE, :
System command 'R' failed, exit status: 1, stdout + stderr (last 10 lines):
E> /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp:58:13: note: template argument deduction/substitution failed:
E> /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp: In substitution of ‘template<class T> using is_convertible_to_cpp11_string = typename std::enable_if<(std::is_convertible<T, cpp11::r_string>::value && (! std::is_convertible<T, const char*>::value)), T>::type [with T = std::map<double, int>]’:
E> /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp:57:60: required from here
E> /home/mads/R/x86_64-pc-linux-gnu-library/3.6/cpp11/include/cpp11/r_string.hpp:52:7: error: no type named ‘type’ in ‘struct std::enable_if<false, std::map<double, int> >’
E> 52 | using is_convertible_to_cpp11_string =
E> | ^~~~~~~~~~~~~~~~~~~~~~~~
[...]
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C