Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368099 - CDT fails to remove overload from overload set due to substitution error (another one)
Summary: CDT fails to remove overload from overload set due to substitution error (ano...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 8.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.1.1   Edit
Assignee: Sergey Prigogin CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on: 299911
Blocks:
  Show dependency tree
 
Reported: 2012-01-08 05:56 EST by Nathan Ridge CLA
Modified: 2012-08-18 23:27 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge CLA 2012-01-08 05:56:53 EST
A simple modification to the example from comment 2 to https://bugs.eclipse.org/bugs/show_bug.cgi?id=365981 still produces an error:

template <bool, typename _Tp = void>
struct enable_if
{
};

template <typename _Tp>
struct enable_if<true, _Tp>
{
    typedef _Tp type;
};

template <typename T, typename Signature>
struct has_foo
{
    template <typename U, U> struct type_check;
    template <typename X> static char (& chk(type_check<Signature, &X::foo>
*))[1];
    template <typename  > static char (& chk(...))[2];
    static bool const value = sizeof(chk<T>(0)) == 1;
};

template <typename T>
bool bar(T);

template <typename T>
bool bar(T, typename enable_if<!has_foo<T, void(T::*)()>::value>::type* = 0);

struct S
{
    void foo();
};

int main()
{
    bar(S());  // ERROR HERE: 'bar' is ambiguous
}

Here, has_foo<S, void(S::*)()>::value is true, so enable_if<false> gets instantiated; enable_if<false>::type produces a substitution error, and therefore the second overload of bar() should be removed from the overload resolution set.
Comment 1 Sergey Prigogin CLA 2012-08-18 23:27:43 EDT
Fixed together with bug 299911.