diff -r 66156a3498ea -r b4af20d02ae0 lemon/glpk.h --- a/lemon/glpk.h Mon Mar 14 08:56:54 2011 +0100 +++ b/lemon/glpk.h Fri Apr 15 09:26:09 2011 +0200 @@ -25,16 +25,28 @@ #include -// forward declaration -#if !defined _GLP_PROB && !defined GLP_PROB -#define _GLP_PROB -#define GLP_PROB -typedef struct { double _opaque_prob; } glp_prob; -/* LP/MIP problem object */ -#endif - namespace lemon { + namespace _solver_bits { + class VoidPtr { + private: + void *_ptr; + public: + VoidPtr() : _ptr(0) {} + + template + VoidPtr(T* ptr) : _ptr(reinterpret_cast(ptr)) {} + + template + VoidPtr& operator=(T* ptr) { + _ptr = reinterpret_cast(ptr); + return *this; + } + + template + operator T*() const { return reinterpret_cast(_ptr); } + }; + } /// \brief Base interface for the GLPK LP and MIP solver /// @@ -43,8 +55,7 @@ class GlpkBase : virtual public LpBase { protected: - typedef glp_prob LPX; - glp_prob* lp; + _solver_bits::VoidPtr lp; GlpkBase(); GlpkBase(const GlpkBase&); @@ -122,9 +133,9 @@ public: ///Pointer to the underlying GLPK data structure. - LPX *lpx() {return lp;} + _solver_bits::VoidPtr lpx() {return lp;} ///Const pointer to the underlying GLPK data structure. - const LPX *lpx() const {return lp;} + _solver_bits::VoidPtr lpx() const {return lp;} ///Returns the constraint identifier understood by GLPK. int lpxRow(Row r) const { return rows(id(r)); }