|
Boost Users : |
From: Simon Bailey (conic_at_[hidden])
Date: 2003-04-09 22:08:40
To get around the template problems, I had to write my own mini-
version of boost::function and change boost::thread to use that
instead!
Update thread.hpp and thread.cpp to accept a const ref to function
class below...
#define SunWS when compiling!
Also make sure you all the latest patches for the Sun compiler.
/////////////////////////////////////////////////////////////////////
/
// function.hpp
//
// This file includes a workaround for the Sun WorkShop compiler
which
// core dumps when trying to compile boost::function<>
/////////////////////////////////////////////////////////////////////
/
#if !defined(WU_FUNCTION_H_)
#define WU_FUNCTION_H_
#if !defined(SunWS)
#include <boost/function.hpp>
namespace WUC2
{
typedef boost::function0<void> Callback;
} // namespace WUC2
/////////////////////////////////////////////////////////////////////
/
#else
#include <memory>
namespace WUC2
{
#if !defined(WU_FUNCTION_HOLDER_BASE_H_)
#define WU_FUNCTION_HOLDER_BASE_H_
class function_holder_base // detail
{
public:
virtual ~function_holder_base() {}
virtual void operator()() = 0;
virtual function_holder_base* copy() const = 0;
};
#endif // !defined(WU_FUNCTION_HOLDER_BASE_H_)
template<typename F>
class function_holder : public function_holder_base // detail
{
public:
function_holder(const F& f) : m_f(f) {}
~function_holder() {}
void operator()() { m_f(); }
function_holder_base* copy() const { return new
function_holder(*this); }
private:
F m_f;
};
class function
{
public:
template<typename F> function(const F& fb) : m_fb
(new function_holder<F>(fb)) {}
function(const function& r) : m_fb( (r.m_fb)->copy
() ) {}
function() : m_fb(0) {}
function& operator=(const function& r)
{
std::auto_ptr<function_holder_base> fb(
(r.m_fb)->copy() );
if(fb.get())
{
delete m_fb;
m_fb = fb.release();
}
return *this;
}
~function() { delete m_fb; }
void operator()() { m_fb->operator()(); }
operator bool() const { return m_fb != 0; }
void clear() { delete m_fb; m_fb = 0; }
private:
function_holder_base* m_fb;
};
typedef function Callback;
} // namespace WUC2
/////////////////////////////////////////////////////////////////////
/
#endif // elif !defined(SunWS)
/////////////////////////////////////////////////////////////////////
/
#endif // !defined(WU_FUNCTION_H_)
--- In Boost-Users_at_[hidden], "jenny_qzhang"
<jenny_qzhang_at_y...> wrote:
> Hi, All
>
> I am working on porting an application from MSVC to solaris
> workshop(the applicatoin is using boost thread lib). I could not
> locate the makefile or jam file for this compiler. Is there
anybody
> did the same thing before?
>
> If you finially made it, can you share your experience,
makefile
> with me? Actually I tried to write a makefile myself, but it
reported
> a lot of errors related to template parameters :(.
>
>
> Thanks very much!
>
> Qiu
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net