|
Boost Users : |
Subject: [Boost-users] Ambiguous overload for boost::blank when using optional & variant
From: Berteun Damman (berteun_at_[hidden])
Date: 2015-01-14 07:09:47
Hi,
I'm using boost 1.57 after upgrading from 1.50, and the following
innocuous looking program does not compile with either GCC (4.9) or
Clang (3.5); tested both on Mac & Linux:
#include <boost/optional.hpp> // This header triggers the problem
#include <boost/variant.hpp>
int main() {
boost::variant<boost::blank> a, b;
swap(a,b); // a.swap(b) does not make a difference
}
Both GCC and Clang give the same error:
/opt/local/include/boost/variant/detail/move.hpp:60:5: error: call to
'swap' is ambiguous
swap(lhs, rhs);
[....]
/opt/local/include/boost/core/swap.hpp:54:8: note: candidate function
[with T1 = boost::blank, T2 = boost::blank]
void swap(T1& left, T2& right)
^
/opt/local/include/boost/variant/detail/move.hpp:44:13: note:
candidate function [with T1 = boost::blank, T2 =boost::blank]
inline void swap(T1& lhs, T2& rhs)
In this case one could remove the Optional header, but in a larger
project this is of course not a solution; a better solution seems to
add an overload for swap taking two boost blanks.
I feel this is a bug in Boost, can someone confirm and tell me where I
should file the bug request?
Finally I noticed due to the above error messages that boost::variant
will never use variadic templates when you use Clang. For GCC it uses
them (in C++11 mode), but for Clang it refuses. Why is this?
Thanks,
-Berteun
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