-Wdeprecated-literal-operator(#447,cpp11 now requires R >=4.0.0, in line with thetidyverseversion policy (#411).
Because cpp11 now requires R >=4.0.0, a number of previouslyoptional tools are now always available, allowing us to remove some deadcode. In particular:
R_UnwindProtect() is always available, so thedefinesHAS_UNWIND_PROTECT andCPP11_UNWINDare no longer useful.
ALTREP is always available, so the filecpp11/altrep.hpp and the defineHAS_ALTREP areno longer useful.
We would like to remove the dead code regarding these tools in thefuture, so we ask that you please remove usage of them from your ownpackages (#411).
R_NO_REMAP andSTRICT_R_HEADERS are nowconditionally defined only if they have not already been definedelsewhere. This is motivated by the fact thatR_NO_REMAP isbecoming the default for C++ code in R 4.5.0 (#410).
Fixed a small protection issue flagged by rchk (#408).
Removed usage of the following R non-API functions:
SETLENGTH()
SET_TRUELENGTH()
SET_GROWABLE_BIT()
These functions were used as part of the efficient growable vectorsthat cpp11 offered, i.e. what happens under the hood when you usepush_back(). The removal of these non-API functions meansthat cpp11 writable vectors that have been pushed to withpush_back() will likely force 1 extra allocation when theconversion fromcpp11::writable::r_vector<T> toSEXP occurs (typically when you return a result back to R).This does not affect the performance ofpush_back() itself,and in general these growable vectors are still quite efficient(#362).
Theenvironment class no longer uses the non-APIfunctionRf_findVarInFrame3() (#367).
Theexists() method now uses the newR_existsVarInFrame() function.
TheSEXP conversion operator now uses the newR_getVar() function. Note that this is stricter thanRf_findVarInFrame3() in 3 ways. The object must exist inthe environment (i.e. R_UnboundValue is no longerreturned), the object cannot beR_MissingArg, and if theobject was a promise, that promise is now evaluated. We have backportedthis new strictness to older versions of R as well.
cpp11::writable::r_vector<T>::proxy nowimplements copy assignment. Practically this means thatx[i] = y[i] now works when bothx andy are writable vectors (#300, #339).
Newwritable::data_frame constructor that also takesthe number of rows as input. This accounts for the edge case where theinput list has 0 columns but you’d still like to specify a known numberof rows (#272).
std::max_element() can now be used with writablevectors (#334).
Read onlyr_vectors now have a move constructor andmove assignment operator (#365).
Repeated assignment to acpp11::writable::stringsvector through eitherx[i] = elt orx.push_back(elt) is now more performant, at the tradeoff ofslightly less safety (as long aselt is actually aCHARSXP andi is within bounds, there is nochance of failure, which are the same kind of invariants placed on theother vector types) (#378).
Constructors for writable vectors frominitializer_list<named_arg> now check thatnamed_arg contains a length 1 object of the correct type,and throws either acpp11::type_error orstd::length_error if that is not the case (#382).
cpp11::package now errors if given a package namethat hasn’t been loaded yet. Previously it would cause R to hangindefinitely (#317).
cpp11::function now protects its underlyingfunction, for maximum safety (#294).
cpp11::writable::r_vector<T>::iterator nolonger implicitly deletes its copy assignment operator (#360).
Added the missing implementation forx.at("name")for read only vectors (#370).
Fixed an issue with thewritable::matrix copyconstructor where the underlying SEXP should have been copied but wasnot. It is now consistent with the behavior of the equivalentwritable::r_vector copy constructor.
Fixed a memory leak with thecpp11::writable::r_vector move assignment operator(#338).
Fixed an issue where writable vectors were being protected twice(#365).
The approach for the protection list managed by cpp11 has beentweaked slightly. In 0.4.6, we changed to an approach that creates oneprotection list per compilation unit, but we now believe we’ve found anapproach that is guaranteed by the C++ standard to create one protectionlist per package, which makes slightly more sense and still has all thebenefits of the reduced maintanence burden mentioned in the 0.4.6 newsbullet (#364).
A side effect of this new approach is that thepreservedobject exposed throughprotect.hpp no longer exists. Wedon’t believe that anyone was using this. This also means you should nolonger see “unused variable” warnings aboutpreserved(#249).
R >=3.6.0 is now required. This is in line with (and even goesbeyond) the tidyverse standard of supporting the previous 5 minorreleases of R.
Implicit conversion fromsexp tobool,size_t, anddouble has been marked asdeprecated and will be removed in the next version of cpp11. The 3packages that were using this have been notified and sent PRs. Therecommended approach is to instead usecpp11::as_cpp<T>, which performs type and lengthchecking, making it much safer to use.
Dropped support for gcc 4.8, mainly an issue for extremely oldCentOS 7 systems which used that as their default compiler. As of June2024, CentOS 7 is past its vendor end of support date and therefore alsoout of scope for Posit at this time (#359).
R >=3.5.0 is now required to use cpp11. This is in line with(and even goes beyond) the tidyverse standard of supporting the previous5 minor releases of R. It also ensures thatR_UnwindProtect() is available to avoid C++ memory leaks(#332).
cpp11::preserved.release_all() has been removed.This was intended to support expert developers on R <3.5.0 when cpp11used a global protection list. Since cpp11 no longer uses a globalprotection list and requires R >=3.5.0, it is no longer needed. Asfar as we can tell, no package was actively using this (#332).
cpp11 now creates one protection list per compilation unit,rather than one global protection list shared across compilation unitsand across packages. This greatly reduces the complexity of managing theprotection list state and should make it easier to make changes to theprotection list structure in the future without breaking packagescompiled with older versions of cpp11 (#330).
Nested calls tocpp11::unwind_protect() are nolonger supported or encouraged. Previously, this was something thatcould be done for performance improvements, but ultimately this featurehas proven to cause more problems than it is worth and is very hard touse safely. For more information, see the newvignette("FAQ") section titled “Should I callcpp11::unwind_protect() manually?” (#327).
The features and bug fixes from cpp11 0.4.4 have been added backin.
Davis Vaughan is now the maintainer.
as_doubles() andas_integers() nowpropagate missing values correctly (#265, #319).
Fixed a performance issue related to nestedunwind_protect() calls (#298).
Minor performance improvements to the cpp11 protect code. (
cpp_register() gains an argumentextension= governing the file extension of thesrc/cpp11 file. By default it’s.cpp, but.cc is now supported as well (#292,
Modernized the GitHub Actions workflows and updated some internaltests to better align with changes in those workflows and the latestversion of R (#279).
cpp_source() errors on non-existent file(#261).
cpp_register() is quiet by default when R is noninteractive (#289).
updated test to adapt to changes in R 4.2.1 (#290).
cpp11::messages()cpp11::stop() andcpp11::warning(). Set theCPP11_USE_FMT macroto use this feature in your package. (as_double() andas_integer() methodsto coerce integers to doubles and doubles to integers to doubles (cpp11::matrix iterators can now be used either row-wiseor column-wise (the default) depending on the user’s choice (writable::r_vector default constructors now return a 0length vector when converted toSEXP (#166)r_vector constructors now disallow implicitconstruction with named arguments (#237)r_vector.attr() methods now return constobjects, so it is a compile time error to try to assign to them(#237)+ and+= operators ofr_vector::[const_]iterator to conform theiterators concept:+= updates the iterator, and+ returns the updated copy, while keeping the originalunchanged (@alyst,#231)cpp11::sexps (#224).Call calls in cpp11.cpp file (cpp_register() now includesattribute_visible in the init function, so packagescompiled withC_VISIBILITY will find the initfunction.cpp_source() on the same filemore than once (cpp11::linking_to(@sbearrows,#193)cpp11::stop() andreplaced with C++ exceptions (x.empty() method to check if a vector is empty(@sbearrows,#182)x.named() method to check if a vector is named(@sbearrows,#186)na() free function to return the NA sentinels for Robjects (tools::package_native_routine_registration_skeleton()(@sbearrows,#171)cpp11::unwind_protect() andcpp11::safe(#154)cpp_source() now gets an argumentdir toallow customized temporary directory to store generated source files. Itmakes it easier to debug C++ source files in non-package project viasource mapping. (cpp_register() now uses symbols exclusively in the.Call() interface. This allows it to be more robust ininteractive use with the pkgload package.cpp_source() gains acxx_std argument tocontrol which C++ standard is used. This allows you to use code fromC++14 and later standards with cpp_source(). (#100)cxx_std chunk option to control the C++ standard used.cpp_source() now has much more informative errormessages when compilation fails (#125, #139)cpp_source() now uses a unique name for the DLL, soworks when run multiple times on the same source file on Windows(#143)writable::list_of<T> now supports modification ofvectors as intended (#131).tools::package_native_routine_registration_skeleton() areno longer swallowed (#134)cpp_source() can now accept a source file calledcpp11.cpp (#133)named_arg now explicitly protect their values, avoidingprotection issues when using large inputs.tidyverse/readr#1145r_string(std::string) now usesRf_mkCharLenCE() instead ofRf_mkChar(), whichavoids the performance cost of checking the string length.r_vector::const_iterator::operator* is now a constmethod (#113,@bkietz,@xhochy)r_bool added as an adapter betweenboolandRboolean values (#57,
data_frame() objects now have the number of rowscorrectly set as real length, not the reserved length (#91)
Fixed potential memory leak in cpp11::writable classes.
Ensures backwards compatibility with code generation from cpp110.1.0 (#88)
push_back() now works more consistently with namedarguments (#86)
cpp11 is now able to compile on gcc 4.8.5 (#69,
cpp_source(),cpp_function() andcpp_eval() now support[[cpp11::linking_to()]]syntax to link to third party packages with C++ headers. (#48)
as_cpp<E>() now works with enumeration types(#52,
as_cpp<int>() andas_cpp<double>() now implicitly coerce between all 3types of single NA values (#53).
list::const_iterator::operator*() added so iteratorscould be used on list objects (#60,
safe[] can now work with functions that return anytype (#70,
TheEND_CPP macro now includes acatch(...) block to catch all C++ exceptions that do notinherit fromstd::exception (#47).
Improve consistency of inserting NA values in r_string objects(#45)
Added aNEWS.md file to track changes to thepackage.