Boost logo

Boost Users :

Subject: Re: [Boost-users] Change return type automatically
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-30 09:56:53


AMDG

Surya Kiran Gullapalli wrote:
>> If you can use compile time constants instead of runtime values,
>> you can use indices into a fusion::vector.
>>
>
>
> The SignalId I'm talking about is a compile time constant (an enum)
> I'm trying this, but could not get anywhere for the past few days. Any
> pointers on this ?
>

#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/at.hpp>

class A {
private:
    typedef boost::fusion::vector<
        boost::signal<void()>,
        boost::signal<void (const string&)>
> signals_type;
    signals_type m_signals;
public:
    static const int VoidSignal = 0;
    static const int StringSignal = 1;
    template<int ID>
    typename boost::fusion::result_of::at_c<signals_type, ID>::type
    getSignal() { return boost::fusion::at_c<ID>(m_signals); }
};

void f() {
    A a;
    a.getSignal<A::VoidSignal>()
}

In Christ,
Steven Watanabe


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