13
0

Fix Searchpath::operator+ to return by value rather than reference and not modify *this

ladspa_search_path was the only function using this API and it is unaffected by
the change
This commit is contained in:
Tim Mayberry 2014-07-09 11:03:21 +10:00
parent 6847b59721
commit ea32eecf3d
2 changed files with 6 additions and 9 deletions

View File

@ -90,12 +90,12 @@ public:
/**
* Concatenate another Searchpath onto this.
*/
LIBPBD_TEMPLATE_MEMBER_API Searchpath& operator+ (const Searchpath& other);
LIBPBD_TEMPLATE_MEMBER_API const Searchpath operator+ (const Searchpath& other);
/**
* Add another path to the search path.
*/
LIBPBD_TEMPLATE_MEMBER_API Searchpath& operator+ (const std::string& directory_path);
LIBPBD_TEMPLATE_MEMBER_API const Searchpath operator+ (const std::string& directory_path);
/**
* Remove all the directories in path from this.

View File

@ -124,19 +124,16 @@ Searchpath::operator+= (const std::string& directory_path)
return *this;
}
Searchpath&
const Searchpath
Searchpath::operator+ (const std::string& directory_path)
{
add_directory (directory_path);
return *this;
return Searchpath (*this) += directory_path;
}
Searchpath&
const Searchpath
Searchpath::operator+ (const Searchpath& spath)
{
// concatenate paths into new Searchpath
insert(end(), spath.begin(), spath.end());
return *this;
return Searchpath (*this) += spath;
}
Searchpath&