clang++ will not build first example in boost signals2

150 Views Asked by At

Hey everyguys I've been taking a look at boost signals recently because I'd like to switch over to it from my own custom code for handling signal notification. I ran into a problem compiling the first example from here: http://www.boost.org/doc/libs/1_53_0/doc/html/signals2/tutorial.html, here is the example source code:

struct HelloWorld
{
  void operator()() const
  {
    std::cout << "Hello, World!" << std::endl;
  }
};

// Signal with no arguments and a void return value
boost::signals2::signal<void ()> sig;

// Connect a HelloWorld slot
HelloWorld hello;
sig.connect(hello);

// Call all of the slots
sig();

The problem that arose from attempting to compile this with: clang++ -std=c++11 signals2example.cpp is this error here:

 error: no matching function for call to 'get'
          func(std::get<indices>(args)...);

To narrow down the problem I commented out all the lines until I figured out which one caused it, it was the line that simply says "sig();" and the problem seems to be related to the std::get function which is for tuples or something. There are not many helpful posts online with regards to boost::signal2 and clang++ clashing. I should also note that g++ compiles this document with no complaints at all.

1

There are 1 best solutions below

0
On

When you are compiling with Clang and you use the STL, the system STL (usually libstdc++) is used. It can be an old version (Do you use OSX?). Clang has perfect support for C++11 with libc++, try adding -stdlib=libc++ to the command line. You may also try to run both gcc and clang with -v and check the include paths to see which stdlib is used in each case.