Opened 9 years ago

Closed 9 years ago

#9286 closed Patches (fixed)

signals2 compile error with MSVC12 and variadic templates

Reported by: raad@… Owned by: Frank Mori Hess
Milestone: To Be Determined Component: signals2
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

With variadic templates enabled, the following code doesn't compile with Microsoft Visual C++ 12 (2013):

boost::signals2::signal<void (const std::wstring &, int)> someSignal; someSignal.connect(boost::bind(&SomeMemberFunction, this, _1, _2));

Making the variadic constructor explicit fixes the issue. Patch for variadic_slot.hpp (against trunk r86387) attached.

Attachments (1)

variadic_slot.hpp.patch (512 bytes ) - added by raad@… 9 years ago.
Make variadic slot contructor explicit

Download all attachments as: .zip

Change History (7)

by raad@…, 9 years ago

Attachment: variadic_slot.hpp.patch added

Make variadic slot contructor explicit

comment:1 by raad@…, 9 years ago

Sorry, it actually fixes only my use case, but of course breaks code using the implicit BindArgs... constructor.

comment:2 by raad@…, 9 years ago

The problem is that VC++12 prefers the variadic slot constructor over the non-variadic constructor, so calling slot(boost::bind(...)) always calls boost::bind(boost::bind(...)), which doesn't compile.

If I understand the example in 14.8.2.4.8 of the January 2012 C++ working draft correctly, this is a compiler bug, so I have filed a bug on Microsoft Connect (ID 806150).

comment:3 by Frank Mori Hess, 9 years ago

(In [86412]) As per Peter Dimov's suggestion, the variadic binding constructor for slots shouldn't accept zero arguments. There is also no need for it to accept a single argument, and not doing so avoids a bug in MSVC12. Refs #9286

comment:4 by raad@…, 9 years ago

The code compiles file now. Thank you!

comment:5 by raad@…, 9 years ago

The code compiles fine now. Thank you!

comment:6 by Frank Mori Hess, 9 years ago

Resolution: fixed
Status: newclosed

(In [86424]) Merged changeset 86412 from trunk. Fixes #9286

Note: See TracTickets for help on using tickets.