Subject: [Boost-bugs] [Boost C++ Libraries] #11570: Boost 1.59.0 breaks lexical_cast to a move-only type (from a string)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-08-23 15:57:59
#11570: Boost 1.59.0 breaks lexical_cast to a move-only type (from a string)
-------------------------------------------------+-------------------------
Reporter: Tony Lewis <tonyelewis@â¦> | Owner: apolukhin
Type: Bugs | Status: new
Milestone: To Be Determined | Component:
Version: Boost 1.59.0 | lexical_cast
Keywords: lexical_cast,move-only,1.59.0,copy | Severity: Regression
constructor,regression |
-------------------------------------------------+-------------------------
I think lexical_cast 1.59.0 introduces a regression over 1.58.0 because
1.58.0 allows lexical_cast from string to a move-only type but this now
fails to compile.
C++11 example:
{{{
#!cpp
#include <boost/lexical_cast.hpp>
#include <iostream>
#include <string>
using boost::lexical_cast;
using namespace std;
struct my_move_only final {
string data;
my_move_only() = default;
my_move_only(my_move_only &&) = default;
my_move_only(const my_move_only &) = delete;
};
istream & operator>>(istream &arg_is, my_move_only &arg_mot) {
arg_is >> arg_mot.data;
return arg_is;
}
int main() {
cerr << "from string gives : " << lexical_cast<my_move_only>(
string{ "mr_carbohdrate" } ).data << endl;
}
}}}
This works against Boost 1.58.0 under both `g++ -std=c++11` and `clang++
-std=c++11 -stdlib=libc++` but fails against Boost 1.59.0 under both.
The key compile error message appears to be:
{{{
boost/lexical_cast.hpp:46:26: error: use of deleted function
âmy_move_only::my_move_only(const my_move_only&)â
return get(result);
}}}
(ie, you're trying to copy-construct this move-only type).
It looks to me like this functionality broke with commit
[https://github.com/boostorg/lexical_cast/commit/bdc355759e3259209f1107ae21babee6dcf8d80b
bdc355759e].
Is it possible to keep that commit's benefits whilst restoring support for
move-only types? Perhaps with some `std::move()` magic?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11570> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC