[Boost-bugs] [Boost C++ Libraries] #5301: Boost.Filesystem V3 interface inconsistency

Subject: [Boost-bugs] [Boost C++ Libraries] #5301: Boost.Filesystem V3 interface inconsistency
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-13 21:03:22


#5301: Boost.Filesystem V3 interface inconsistency
--------------------------------------------------------+-------------------
 Reporter: Peter Klotz <peter.klotz@…> | Owner: bemandawes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.46.0 | Severity: Problem
 Keywords: |
--------------------------------------------------------+-------------------
 I came across the following interface inconsistency in Boost.Filesystem V3
 (Boost 1.46.0) in boost::filesystem::path

 Windows:

 const std::string string()
 const std::wstring& wstring()

 Linux:

 const std::string& string()
 const std::wstring wstring()


 We converted V2 code looking like this (necessary since filename() in V3
 returns a path instead of a string):

 const std::string& filename=path.filename();

 The converted V3 code:

 const std::string& filename=path.filename().string();


 Obviously this code crashes in Linux since filename() returns a temporary
 object and string() returns a reference to one of its members.

 However this code works in Windows due to the different return types.

 My question:

 Wouldn't it make sense for all methods to return a value instead of a
 reference?

 It would ease the transition from V2 to V3 and avoid subtle programming
 errors.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5301>
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:05 UTC