This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Implement ISO/IEC TS 18822 C++ File system TS


On 01/05/15 19:03 +0200, Daniel Krügler wrote:
b/libstdc++-v3/src/filesystem/path.cc:

- path::compare(const path& p) const noexcept:

Shouldn't the implementation of this noexcept function not try to
create copies of path objects? Couldn't _Cmpt just hold references to
_M_pathname?

All your other comments are definitely correct and I'll make the
relevant fixes soon, but I'm not sure what you mean here, could you
clarify?

I think it would be possible to implement a path like:

 class path
 {
   using value_type = ...;
   using string_type = basic_string<value_type>;
   struct _Cmpt;
   using composite_path = pair<string_type, list<_Cmpt>>;
   using sub_path = basic_string_view<value_type>;

   variant<composite_path, sub_path> _M_data;
   enum _Type { ... } _M_type;
 };

 struct _Cmpt : path
 {
   // ...
 };

With the invariant that for all objects of type _Cmpt the variant
member holds a string_view that refers to the string_type object in
some other path.

This would reduce the memory footprint of a path object (but for the
new std::string ABI, only if there are path components longer than the
SSO small string buffer). Even with that design, paths would still
be sizeof(string_type) + sizeof(std::list<_Cmpt>) + sizeof(_Type).

Alternatively, it could be done without a variant, just adding a
string_view member to the path type, which would make it even larger,
but would simplify the implementation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]