romainfrancois commented on a change in pull request #7819: URL: https://github.com/apache/arrow/pull/7819#discussion_r471347426
########## File path: r/src/arrow_cpp11.h ########## @@ -0,0 +1,243 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include <limits> +#include <memory> +#include <utility> +#include <vector> +#undef Free + +namespace cpp11 { + +template <typename T> +SEXP as_sexp(const std::shared_ptr<T>& ptr); + +template <typename T> +SEXP as_sexp(const std::vector<std::shared_ptr<T>>& vec); + +template <typename E, typename std::enable_if<std::is_enum<E>::value>::type* = nullptr> +SEXP as_sexp(E e); + +} // namespace cpp11 + +#include <cpp11.hpp> Review comment: The `as_sexp()` just above need to happen before including `cpp11.hpp` otherwise we get something like this: ``` de' -I/usr/local/include -fPIC -Wall -O3 -Wall -Wimplicit-int-float-conversion -c filesystem.cpp -o filesystem.o In file included from filesystem.cpp:18: In file included from ././arrow_types.h:22: In file included from ././arrow_cpp11.h:24: In file included from /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11.hpp:7: In file included from /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/data_frame.hpp:12: In file included from /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/list.hpp:7: /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/named_arg.hpp:21:14: error: call to function 'as_sexp' that is neither visible in the template definition nor found by argument-dependent lookup value_ = as_sexp(rhs); ^ filesystem.cpp:230:41: note: in instantiation of function template specialization 'cpp11::named_arg::operator=<std::__1::shared_ptr<arrow::fs::FileSystem> >' requested here return cpp11::writable::list({"fs"_nm = file_system, "path"_nm = out_path}); ^ ././arrow_cpp11.h:227:6: note: 'as_sexp' should be declared prior to the call site or in namespace 'arrow::fs' SEXP as_sexp(const std::shared_ptr<T>& ptr) { ^ ``` I'm not sure there is a cpp11 solution for this. cc @jimhester ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
