1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
// Copyright (c) 2014 GeometryFactory Sarl (France)
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Andreas Fabri, Laurent Rineau
//| This flag is set if the compiler bugs with some "using Base::Member;" in
//| a derived class. The workaround is to write a forwarder or not use
//| using.
enum Type { POINT, WPOINT };
#include <cassert>
int I;
struct Point {
};
struct WPoint
{
WPoint(const Point&) {} // Point is implicitly convertible to WPoint.
};
struct Conv
{
Conv() {}
template <typename T>
Type operator()(const T&){ return POINT; }
};
struct WConv : Conv
{
WConv() {}
Type operator()(const WPoint&){ return WPOINT; }
#if MATCHING_BUG_8 // only defined by CGAL_CFG_MATCHING_BUG_8.cpp
Type operator()(const Point&){ return POINT; }
#endif
using Conv::operator(); // Import the operator() of Conv, that matches
// for every type.
// Workaround: comment the previous 'using' line, and write:
// template <typename T>
// Type operator()(const T& t){ return Conv::operator()(t); }
};
int main()
{
I = 0;
Point p;
WPoint wp(p);
WConv wconv;
if(wconv(p) != POINT) return 1;
if(wconv(wp) != WPOINT) return 1;
return 0;
}
// VC++11 and VC++12 both say that the call to `wconv(p)` is ambiguous:
//
// config\testfiles\CGAL_CFG_MATCHING_BUG_7.cpp(61) : error C2666: 'WConv::operator ()' : 2 overloads have similar conversions
//
// config\testfiles\CGAL_CFG_MATCHING_BUG_7.cpp(51): could be 'void WConv::operator ()(const WPoint &)'
//
// unable to recover from previous error(s); stopping compilation
|