Opened 9 years ago
Closed 7 years ago
#9754 closed Bugs (invalid)
boost::is_function VS compile error (for const operator function)
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | type_traits |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | boost::is_function, compile error | Cc: |
Description
If you try to evaluate boost::is_function on functions that have the same signature and one of them are member const operator function, VC++ (10 through 12) fires compile error:
Sample minimal code:
struct Functor {
void operator()() const {} };
boost::is_function<void()>::value; boost::is_function<decltype(Functor().operator())>::value;
Compiler output: 1>$(path)\boost\type_traits\is_function.hpp(72): error C2373: 't' : redefinition; different type modifiers 1> $(path)\boost\type_traits\is_function.hpp(72) : see declaration of 't' 1> $(path)\boost\type_traits\is_function.hpp(97) : see reference to class template instantiation 'boost::detail::is_function_impl<T>' being compiled
Attachments (1)
Change History (3)
by , 9 years ago
Attachment: | sample.cpp added |
---|
comment:1 by , 9 years ago
I'm not completely sure but I think there's a problem with your use of decltype: gcc for example won't allow it to be used in this way (even if you remove the is_function usage). If you pass the actual type of the member function to is_function then there's no issue. So my suspicion is that is_function is a bystander in this.
comment:2 by , 7 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Double checking, I'm pretty sure the code is mal-formed, the correct form is:
boost::is_function<decltype(std::declval<Functor>()())>::value;
Which does work just fine in your example.
sample code