Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9279545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:39:38+00:00 2026-06-18T17:39:38+00:00

I found this C++ code that uses boost signals and I’m trying to understand

  • 0

I found this C++ code that uses boost signals and I’m trying to understand it.

// A boost::signal wrapper structure 
template <typename Signature>
struct SignalBase : public boost::noncopyable
{
    typedef boost::function_traits< Signature >        SignatureTraits;

    typedef boost::signal<Signature>                   SignalType;
    typedef typename SignalType::slot_function_type    SlotFunctionType;
    typedef typename SignalType::result_type           ResultType;
    typedef boost::signals::connection                 ConnectionType;

    SignalBase() : m_signal() {};
    virtual ~SignalBase() {};

protected:
    SignalType m_signal;
};


// I use a specialization of this template for an arity of 1.
// The template generates the correct function call operator for the arity of the signal.
template<int Arity, typename Signature>
struct SelArity : public SignalBase<Signature> {};

// Specialization
template<typename Signature>
struct SelArity< 1, Signature> : public SignalBase<Signature>
{
    typedef SignalBase<Signature> BaseType;
    inline typename BaseType::ResultType operator()(typename BaseType::SignatureTraits::arg1_type arg )
    {
        return BaseType::m_signal( arg );
    }
};

I can’t figure out what SelArity functors will return. As far as I understand m_signal is a type which can declare signals that will be able to connect to functions with Signature signature. How is it possible to have types as parameters?( see return BaseType::m_signal( arg ); ) What is the type represented by ResultType ? And how will I be able to use the object returned by SelArity functor?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T17:39:40+00:00Added an answer on June 18, 2026 at 5:39 pm

    No, m_signal is not a type, it’s an instance of class SignalType, which is boost::signal<Signature>.

    SelArity functor actually invokes m_signal with 1 argument and returns its return value.

    (What all these wrappers are needed for I don’t know.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to use code I've found that uses Win32. However, I'm getting this
I have this Objective-C code that I found somewhere. Honestly, I don't understand a
I found this code snippet on a different post that I don't quite understand
I'm trying to create something similar as this code found at the boost.asio examples.
I've found this small code that sends email to gmail users. I'd like the
found this little code snippet that seems to do what i want, but im
I found this great code snippet that works wonderfully during circumstances that change a
I currently have this useful code that I found elsewhere on StackOverflow: form.DrawToBitmap(bmp, new
I found that this C++ code: vector<int> a; a.push_back(1); a.push_back(2); vector<int>::iterator it = a.begin();
I have found this line of code in a game that I study int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.