Opened 6 years ago

Closed 6 years ago

#12563 closed Bugs (fixed)

Assigning to boost::optional<std::tuple from std::tuple fails to compile using c++14 and libc++.

Reported by: Andrew King <eurokang@…> Owned by: Fernando Cacciola
Milestone: Boost 1.63.0 Component: optional
Version: Boost 1.62.0 Severity: Regression
Keywords: Cc:

Description

#include <boost/optional.hpp>

#include <tuple>

using Tup = std::tuple<boost::optional<int>>;
Tup x;

boost::optional<Tup> y = x;

when compiled with: clang++-3.7 -std=c++14 -stdlib=libc++ temp.cpp fails to compile:

error: no matching member function for call to
      'construct'
        this->construct( boost::move(rhs.get()) );
        ~~~~~~^~~~~~~~~
/usr/include/c++/v1/tuple:220:15: note: in instantiation of function template specialization
      'boost::optional<int>::optional<std::__1::tuple<boost::optional<int> > >' requested here
            : value(_VSTD::forward<_Tp>(__t))
              ^
/path/boost/1.62.0a-src/boost/boost/optional/optional.hpp:348:10: note: candidate function not viable: no known
      conversion from 'typename ::boost::move_detail::remove_reference<tuple<optional<int> > &>::type' (aka 'std::__1::tuple<boost::optional<int> >') to
      'const int' for 1st argument
    void construct ( argument_type val )
         ^
/path/boost/1.62.0a-src/boost/boost/optional/optional.hpp:355:10: note: candidate function not viable: no known
      conversion from 'typename ::boost::move_detail::remove_reference<tuple<optional<int> > &>::type' (aka 'std::__1::tuple<boost::optional<int> >') to 'int'
      for 1st argument
    void construct ( rval_reference_type val )
         ^
/path/boost/1.62.0a-src/boost/boost/optional/optional.hpp:367:10: note: candidate function [with Args = <>] not viable:
      no known conversion from 'typename ::boost::move_detail::remove_reference<tuple<optional<int> > &>::type' (aka 'std::__1::tuple<boost::optional<int> >')
      to 'boost::optional_ns::in_place_init_t' for 1st argument
    void construct ( in_place_init_t, Args&&... args )
         ^
/path/boost/1.62.0a-src/boost/boost/optional/optional.hpp:544:10: note: candidate function template not viable: requires
      2 arguments, but 1 was provided
    void construct ( Expr&& factory, in_place_factory_base const* )
         ^
/path/boost/1.62.0a-src/boost/boost/optional/optional.hpp:552:10: note: candidate function template not viable: requires
      2 arguments, but 1 was provided
    void construct ( Expr&& factory, typed_in_place_factory_base const* )
         ^
/path/boost/1.62.0a-src/boost/boost/optional/optional.hpp:614:10: note: candidate function template not viable: requires
      2 arguments, but 1 was provided
    void construct ( Expr&& expr, void const* )

Compiling with -std=c++11 and -stdlib=libc++ compiles fine. Compiling with -std=c++14 and -stdlib=libstdc++ compiles fine. Using std::experimental::optional instead of boost::optional compiles fine. Using boost::tuple instead of libc++ std::tuple compiles fine.

So it seems to only be libc++ libc++ tuple with boost::optional and c++14. I am not sure the bug is actually a boost::optional bug, (it may be libc++ or clang) so if this is incorrect please let me know.

Change History (6)

comment:1 by akrzemi1, 6 years ago

Can you still see the bug after my latest commit?

comment:2 by akrzemi1, 6 years ago

Unfortunately, I do not have access to such tuple's source code. Could you send me your tuple header: /usr/include/c++/v1/tuple

comment:3 by eurokang@…, 6 years ago

Yes, the bug still exists after using latest git version of boost::optional.

http://llvm.org/svn/llvm-project/libcxx/trunk/include/tuple

comment:4 by akrzemi1, 6 years ago

Ok, I think I know where the problem is. I have just pushed a commit to branch develop (hash 7ea2ca6). Could you verify if this fixes the problem for you?

comment:5 by anonymous, 6 years ago

Yes, that fixes it! Thanks!

comment:6 by akrzemi1, 6 years ago

Milestone: To Be DeterminedBoost 1.63.0
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.