Opened 10 years ago

Closed 10 years ago

#8313 closed Bugs (wontfix)

const definition of boost::none

Reported by: anonymous Owned by: Fernando Cacciola
Milestone: To Be Determined Component: optional
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

boost provides an object named boost::none of type boost::none_t. it originally stems from Boost.Optional, but since it is in the root directory, boost/none.hpp, I guess it is there for other uses as well.

I tried to use it in the following way, which fails, because of the definition of boost::none:

template<class T,class T2=boost::none_t> struct A{

A(T &a,T2 &b=none);

};

boost::none is an object defined to be const, so it is not accepted as a non-const reference. I don't see a reason why it has to be const. its value is never used anyway.

I'll probably have to use boost::enable_if instead, to enable a "unary" constructor if and only if T2 == boost::none_t

Change History (1)

comment:1 by Steven Watanabe, 10 years ago

Resolution: wontfix
Status: newclosed

You should not use boost::none as an lvalue.

Note: See TracTickets for help on using tickets.