I have a String class that has a member of std :: string. One of the designers
String (std::string s)
{
_mString = s;
}
Now I have functions that take a String parameter as a parameter, for example. Load (String path);
but it turns out that boost :: filesystem :: path :: string () is incompatible with this String constructor, but usually assign ok
boost::filesystem::path somepath("some directory")
std::string filename = somepath.extension();
What's happening? How can I make my constructor work? Thank.
EDIT: The problem is resolved by making it const ref, but still curious why the error is because it seems acceptable to pass a copy because it can be assigned directly. Error in xstring file
void __CLR_OR_THIS_CALL _Tidy(bool _Built = false,
size_type _Newsize = 0)
{ // initialize buffer, deallocating any storage
if (!_Built)
;
else if (_BUF_SIZE <= _Myres)
{ // copy any leftovers to small buffer and deallocate
_Elem *_Ptr = _Bx._Ptr;
if (0 < _Newsize)
_Traits_helper::copy_s<_Traits>(_Bx._Buf, _BUF_SIZE, _Ptr, _Newsize);
_Mybase::_Alval.deallocate(_Ptr, _Myres + 1);
}
_Myres = _BUF_SIZE - 1; // **** ERROR ***
_Eos(_Newsize);
}
source
share