Opened 5 years ago

Closed 5 years ago

#13037 closed Bugs (fixed)

<boost/variant/polymorphic_get.hpp> is missing include <boost/type_traits/is_const.hpp>

Reported by: Adam Badura <adam.f.badura@…> Owned by: Antony Polukhin
Milestone: Boost 1.65.0 Component: variant
Version: Boost 1.64.0 Severity: Problem
Keywords: variant Cc:

Description

Trivial demonstration can be made by preparing a source file containing nothing but an inclusion of the polymorphic_get.hpp:

#include <boost/variant/polymorphic_get.hpp>

on GCC 6.3 with options -Wall -Wextra -std=c++14 compiling such file produces errors:

In file included from Test.cpp:1:0:
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp: In member function ‘boost::detail::variant::get_polymorphic_visitor<Base>::pointer boost::detail::variant::get_polymorphic_visitor<Base>::operator()(U&) const’:
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:121:18: error: ‘is_const’ is not a member of ‘boost’
                 (boost::is_const<base_t>::value || !boost::is_const<U>::value)
                  ^~~~~
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:121:18: note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.3.0/include/c++/bits/move.h:57:0,
                 from /usr/lib/gcc/x86_64-pc-cygwin/6.3.0/include/c++/bits/nested_exception.h:40,
                 from /usr/lib/gcc/x86_64-pc-cygwin/6.3.0/include/c++/exception:171,
                 from /cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:15,
                 from Test.cpp:1:
/usr/lib/gcc/x86_64-pc-cygwin/6.3.0/include/c++/type_traits:652:12: note:   ‘std::is_const’
     struct is_const
            ^~~~~~~~
In file included from Test.cpp:1:0:
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:121:41: error: ‘::value’ has not been declared
                 (boost::is_const<base_t>::value || !boost::is_const<U>::value)
                                         ^~
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:121:53: error: ‘is_const’ is not a member of ‘boost’
                 (boost::is_const<base_t>::value || !boost::is_const<U>::value)
                                                     ^~~~~
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:121:53: note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-cygwin/6.3.0/include/c++/bits/move.h:57:0,
                 from /usr/lib/gcc/x86_64-pc-cygwin/6.3.0/include/c++/bits/nested_exception.h:40,
                 from /usr/lib/gcc/x86_64-pc-cygwin/6.3.0/include/c++/exception:171,
                 from /cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:15,
                 from Test.cpp:1:
/usr/lib/gcc/x86_64-pc-cygwin/6.3.0/include/c++/type_traits:652:12: note:   ‘std::is_const’
     struct is_const
            ^~~~~~~~
In file included from Test.cpp:1:0:
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:121:68: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
                 (boost::is_const<base_t>::value || !boost::is_const<U>::value)
                                                                    ^
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:121:71: error: ‘::value’ has not been declared
                 (boost::is_const<base_t>::value || !boost::is_const<U>::value)
                                                                       ^~
/cygdrive/c/Programming/boost_1_64_0/boost/variant/polymorphic_get.hpp:125:9: error: template argument 2 is invalid
         > tag_t;
         ^

Workaround it trivial - one needs to include is_const.hpp before including polymorphic_get.hpp:

#include <boost/type_traits/is_const.hpp>
#include <boost/variant/polymorphic_get.hpp>

Change History (4)

comment:1 by Adam Badura <adam.f.badura@…>, 5 years ago

I have prepared correction for this bug and issues a pull request with it (https://github.com/boostorg/variant/pull/32).

comment:2 by Adam Badura <adam.f.badura@…>, 5 years ago

Note however that it seems polymorphic_get.hpp header has more such issues: use of elements that are not directly included. Among others there is boost::remove_cv - a problem mentioned in ticket #11283.

Should they be solved as well?

At least as for now they are not causing compilation errors.

comment:3 by Antony Polukhin, 5 years ago

Milestone: To Be DeterminedBoost 1.65.0
Owner: changed from ebf to Antony Polukhin
Status: newassigned

Fixed by Adam Badura in 76b592ae and was merged into the develop in 575c5796.

Will be merged to the master branch as soon as the regression tests cycle.

comment:4 by Antony Polukhin, 5 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.