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

Boost.Function and <boost/bind/apply.hpp> #53

Closed
gast128 opened this issue Oct 12, 2024 · 3 comments
Closed

Boost.Function and <boost/bind/apply.hpp> #53

gast128 opened this issue Oct 12, 2024 · 3 comments

Comments

@gast128
Copy link

gast128 commented Oct 12, 2024

Recently updated to Boost 1.86 and VS2022 (x64) and we get a weird compilation error:

#include <boost/bind/apply.hpp>  // comment this out to get success
#include <boost/bind/bind.hpp>
#include <boost/function.hpp>

int TestArg(int, double)
{
   return 0;
}


void f()
{
   boost::function<int (int)> fn = boost::bind(&TestArg, boost::placeholders::_1, 1.0);
}

Error:

1>D:\Work Sdk\boost_1_86_0\boost\function\function_template.hpp(926,35): error C2977: 'boost::apply': too many template arguments
1>(compiling source file 'Boost.cpp')
1> D:\Work Sdk\boost_1_86_0\boost\bind\apply.hpp(17,26):
1> see declaration of 'boost::apply'
1> D:\Work Sdk\boost_1_86_0\boost\function\function_template.hpp(926,35):
1> the template instantiation context (the oldest one first) is
1> D:\Work\Src\Temp\Bla\Boost.cpp(13,34):
1> see reference to function template instantiation 'boost::function<int (int)>::function<boost::_bi::bind_t<int,int (__cdecl *)(int,double),boost::_bi::list<boost::arg<1>,boost::_bi::value>>>(Functor,int)' being compiled
1> with
1> [
1> T=double,
1> Functor=boost::_bi::bind_t<int,int (__cdecl *)(int,double),boost::_bi::list<boost::arg<1>,boost::_bi::value>>
1> ]
1> D:\Work\Src\Temp\Bla\Boost.cpp(13,34):
1> see the first reference to 'boost::function<int (int)>::function' in 'f'
1> D:\Work Sdk\boost_1_86_0\boost\function\function_template.hpp(1084,24):
1> see reference to function template instantiation 'boost::function_n<R,int>::function_n<boost::_bi::bind_t<R,int (__cdecl *)(int,double),boost::_bi::list<boost::arg<1>,boost::_bi::value>>>(Functor,int)' being compiled
1> with
1> [
1> R=int,
1> T=double,
1> Functor=boost::_bi::bind_t<int,int (__cdecl *)(int,double),boost::_bi::list<boost::arg<1>,boost::_bi::value>>
1> ]
1> D:\Work Sdk\boost_1_86_0\boost\function\function_template.hpp(757,13):
1> see reference to function template instantiation 'void boost::function_n<R,int>::assign_to<boost::_bi::bind_t<R,int (__cdecl *)(int,double),boost::_bi::list<boost::arg<1>,boost::_bi::value>>>(Functor)' being compiled
1> with
1> [
1> R=int,
1> T=double,
1> Functor=boost::_bi::bind_t<int,int (__cdecl *)(int,double),boost::_bi::list<boost::arg<1>,boost::_bi::value>>
1> ]

If one comments out the <boost/bind/apply.hpp>it compiles fine. Using auto or std::function also works.

@pdimov
Copy link
Member

pdimov commented Oct 12, 2024

That's a pretty annoying bug in MSVC; I thought it was no longer an issue in newer versions / later standard modes / /permissive-, but it looks like none of these affect this particular instance of it. :-/

You should report this to MS as a bug; in the meantime I'll try to figure out a way to avoid hitting it.

pdimov added a commit that referenced this issue Oct 12, 2024
@pdimov pdimov closed this as completed in 89dfb03 Oct 12, 2024
@pdimov
Copy link
Member

pdimov commented Oct 12, 2024

I could think of nothing better than renaming the nested apply class template to avoid the conflict (which by the way only happens on msvc-14.3 / VS2022 with /permissive-, not on earlier compiler versions.)

@gast128
Copy link
Author

gast128 commented Oct 13, 2024

Thx. I am a bit reluctant to enter a bug reports since MS has quite the habit with closing them as not reproducible,; not important or not our fault. I tried to reproduce it in compiler explorer but it seems that you cannot use external libraries for the MSVC compiler (it works when using GCC).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants