-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Labels
Description
Expected Behavior
The const-ness of the callable should be propagated to the erased function pointer
Actual Behavior
In file included from main.cpp:1:0:
function2.hpp: In instantiation of ‘static void* fu2::abi_400::detail::type_erasure::address_taker<T, <template-parameter-1-2> >::take(O&&) [with O = const main()::<lambda()>&; T = main()::<lambda()>; <template-parameter-1-2> = void]’:
function2.hpp:1184:51: required from ‘constexpr fu2::abi_400::detail::type_erasure::erasure<false, Config, fu2::abi_400::detail::property<IsThrowing, HasStrongExceptGuarantee, Args ...> >::erasure(T&&) [with T = const main()::<lambda()>&; Config = fu2::abi_400::detail::config<false, true, fu2::capacity_default>; bool IsThrowing = true; bool HasStrongExceptGuarantee = false; Args = {int()}]’
function2.hpp:1376:72: required from ‘constexpr fu2::abi_400::detail::function<Config, fu2::abi_400::detail::property<IsThrowing, HasStrongExceptGuarantee, Args ...> >::function(T&&) [with T = const main()::<lambda()>&; fu2::abi_400::detail::function<Config, fu2::abi_400::detail::property<IsThrowing, HasStrongExceptGuarantee, Args ...> >::enable_if_not_convertible_to_this<T>* <anonymous> = 0; fu2::abi_400::detail::function<Config, fu2::abi_400::detail::property<IsThrowing, HasStrongExceptGuarantee, Args ...> >::enable_if_can_accept_all_t<T>* <anonymous> = 0; fu2::abi_400::detail::function<Config, fu2::abi_400::detail::property<IsThrowing, HasStrongExceptGuarantee, Args ...> >::assert_wrong_copy_assign_t<T>* <anonymous> = 0; fu2::abi_400::detail::function<Config, fu2::abi_400::detail::property<IsThrowing, HasStrongExceptGuarantee, Args ...> >::assert_no_strong_except_guarantee_t<T>* <anonymous> = 0; Config = fu2::abi_400::detail::config<false, true, fu2::capacity_default>; bool IsThrowing = true; bool HasStrongExceptGuarantee = false; Args = {int()}]’
main.cpp:9:42: required from here
function2.hpp:249:26: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
return std::addressof(obj);
Steps to Reproduce
#include "function2.hpp"
int main()
{
const auto callable = []{
return 5;
};
fu2::function_view<int()> view(callable);
}
g++ -std=c++14 main.cpp
Your Environment
>$ g++ --version
g++ (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.