fixed gcc 4.1 compile error

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@56 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
spog 2006-04-23 22:32:51 +00:00
parent 292e05572a
commit 55ceebf861

View file

@ -167,12 +167,26 @@ void CSG_MakeHollow (void)
SceneChangeNotify(); SceneChangeNotify();
} }
template<typename Type>
class RemoveReference
{
public:
typedef Type type;
};
template<typename Type>
class RemoveReference<Type&>
{
public:
typedef Type type;
};
template<typename Functor> template<typename Functor>
class Dereference class Dereference
{ {
const Functor& functor; const Functor& functor;
public: public:
typedef typename Functor::first_argument_type first_argument_type; typedef typename RemoveReference<typename Functor::first_argument_type>::type* first_argument_type;
typedef typename Functor::result_type result_type; typedef typename Functor::result_type result_type;
Dereference(const Functor& functor) : functor(functor) Dereference(const Functor& functor) : functor(functor)
{ {
@ -189,26 +203,29 @@ inline Dereference<Functor> makeDereference(const Functor& functor)
return Dereference<Functor>(functor); return Dereference<Functor>(functor);
} }
typedef Face* FacePointer;
const FacePointer c_nullFacePointer = 0;
template<typename Predicate> template<typename Predicate>
Face* Brush_findIf(const Brush& brush, const Predicate& predicate) Face* Brush_findIf(const Brush& brush, const Predicate& predicate)
{ {
Brush::const_iterator i = std::find_if(brush.begin(), brush.end(), makeDereference(predicate)); Brush::const_iterator i = std::find_if(brush.begin(), brush.end(), makeDereference(predicate));
return i == brush.end() ? 0 : *i; return i == brush.end() ? c_nullFacePointer : *i; // uses c_nullFacePointer instead of 0 because otherwise gcc 4.1 attempts conversion to int
} }
template<typename Caller> template<typename Caller>
class BindArguments1 class BindArguments1
{ {
typedef typename Caller::SecondArgument FirstBound; typedef typename Caller::second_argument_type FirstBound;
FirstBound firstBound; FirstBound firstBound;
public: public:
typedef typename Caller::Return Return; typedef typename Caller::result_type result_type;
typedef typename Caller::FirstArgument FirstArgument; typedef typename Caller::first_argument_type first_argument_type;
BindArguments1(FirstBound firstBound) BindArguments1(FirstBound firstBound)
: firstBound(firstBound) : firstBound(firstBound)
{ {
} }
Return operator()(FirstArgument firstArgument) const result_type operator()(first_argument_type firstArgument) const
{ {
return Caller::call(firstArgument, firstBound); return Caller::call(firstArgument, firstBound);
} }
@ -217,18 +234,18 @@ public:
template<typename Caller> template<typename Caller>
class BindArguments2 class BindArguments2
{ {
typedef typename Caller::SecondArgument FirstBound; typedef typename Caller::second_argument_type FirstBound;
typedef typename Caller::ThirdArgument SecondBound; typedef typename Caller::third_argument_type SecondBound;
FirstBound firstBound; FirstBound firstBound;
SecondBound secondBound; SecondBound secondBound;
public: public:
typedef typename Caller::Return Return; typedef typename Caller::result_type result_type;
typedef typename Caller::FirstArgument FirstArgument; typedef typename Caller::first_argument_type first_argument_type;
BindArguments2(FirstBound firstBound, SecondBound secondBound) BindArguments2(FirstBound firstBound, SecondBound secondBound)
: firstBound(firstBound), secondBound(secondBound) : firstBound(firstBound), secondBound(secondBound)
{ {
} }
Return operator()(FirstArgument firstArgument) const result_type operator()(first_argument_type firstArgument) const
{ {
return Caller::call(firstArgument, firstBound, secondBound); return Caller::call(firstArgument, firstBound, secondBound);
} }