Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make range support conditional #153

Merged
merged 2 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-linux-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
package="$(echo "$body" | sed -n '1p')"
if [ -z "${package}" ]; then
package="CxxWrap"
package="https://github.com/JuliaInterop/CxxWrap.jl.git"
fi
if [[ "$OSTYPE" != "darwin"* ]]; then
rm -f /opt/hostedtoolcache/julia/1.6*/x64/lib/julia/libstdc++.so.6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
cmake -G "Visual Studio 17 2022" -A x64 -DOVERRIDES_PATH=$HOMEDRIVE/$HOMEPATH/.julia/artifacts/Overrides.toml -DOVERRIDE_ROOT=./ -DAPPEND_OVERRIDES_TOML=ON ..
package="$(echo "$body" | sed -n '1p')"
if [ -z "${package}" ]; then
package="CxxWrap"
package="https://github.com/JuliaInterop/CxxWrap.jl.git"
fi
cmake --build . --config Release
julia -e "using Pkg; Pkg.Registry.add(\"General\"); Pkg.Registry.add(RegistrySpec(url = \"https://github.com/barche/CxxWrapTestRegistry.git\"))"
Expand Down
6 changes: 6 additions & 0 deletions include/jlcxx/jlcxx_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@
#define __JLCXX_STR(x) __JLCXX_STR_HELPER(x)
#define JLCXX_VERSION_STRING __JLCXX_STR(JLCXX_VERSION_MAJOR) "." __JLCXX_STR(JLCXX_VERSION_MINOR) "." __JLCXX_STR(JLCXX_VERSION_PATCH)

#if defined __has_include
# if __has_include (<ranges>)
# define JLCXX_HAS_RANGES
# endif
#endif

#endif
2 changes: 2 additions & 0 deletions include/jlcxx/stl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ using stltypes = remove_duplicates<combine_parameterlists<combine_parameterlists
template<typename TypeWrapperT>
void wrap_range_based_algorithms(TypeWrapperT& wrapped)
{
#ifdef JLCXX_HAS_RANGES
using WrappedT = typename TypeWrapperT::type;
using T = typename WrappedT::value_type;
wrapped.module().set_override_module(StlWrappers::instance().module());
wrapped.method("StdFill", [] (WrappedT& v, const T& val) { std::ranges::fill(v, val); });
wrapped.module().unset_override_module();
#endif
}

template<typename T>
Expand Down
3 changes: 3 additions & 0 deletions src/stl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ void wrap_string(TypeWrapper<string_t>&& wrapper)

JLCXX_MODULE define_cxxwrap_stl_module(jlcxx::Module& stl)
{
#ifdef JLCXX_HAS_RANGES
stl.set_const("HAS_RANGES", 1);
#endif
jlcxx::stl::wrap_string(stl.add_type<std::string>("StdString", julia_type("CppBasicString")));
jlcxx::stl::wrap_string(stl.add_type<std::wstring>("StdWString", julia_type("CppBasicString")));

Expand Down
Loading