From 73924c1920af92899f7582cd904ea819b9db35bc Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Thu, 2 Feb 2023 19:58:02 -0500 Subject: [PATCH] Use Brace Lists to initialize objects. (#3277) Co-authored-by: Stephan T. Lavavej --- stl/inc/cvt/wbuffer | 12 +++---- stl/inc/cvt/wstring | 2 +- stl/inc/experimental/filesystem | 58 ++++++++++++++++----------------- stl/inc/filesystem | 32 +++++++++--------- stl/inc/fstream | 8 ++--- stl/inc/istream | 2 +- stl/inc/ostream | 2 +- stl/inc/spanstream | 18 +++++----- stl/inc/sstream | 14 ++++---- stl/inc/streambuf | 6 ++-- stl/inc/strstream | 22 ++++++------- stl/inc/xlocale | 2 +- stl/inc/xlocbuf | 14 ++++---- stl/src/locale0.cpp | 4 +-- 14 files changed, 98 insertions(+), 98 deletions(-) diff --git a/stl/inc/cvt/wbuffer b/stl/inc/cvt/wbuffer index d9ddffe85f..800e436683 100644 --- a/stl/inc/cvt/wbuffer +++ b/stl/inc/cvt/wbuffer @@ -45,7 +45,7 @@ namespace stdext { static state_type _State0; _State = _State0; - _Loc = _STD locale(_Loc, _Pcvt); + _Loc = _STD locale{_Loc, _Pcvt}; } explicit wbuffer_convert(_Mysb* _Strbuf) @@ -53,7 +53,7 @@ namespace stdext { static state_type _State0; _State = _State0; - _Loc = _STD locale(_Loc, _Pcvt); + _Loc = _STD locale{_Loc, _Pcvt}; } wbuffer_convert(_Mysb* _Strbuf, _Codecvt* _Pcvt_arg) @@ -61,13 +61,13 @@ namespace stdext { static state_type _State0; _State = _State0; - _Loc = _STD locale(_Loc, _Pcvt); + _Loc = _STD locale{_Loc, _Pcvt}; } wbuffer_convert(_Mysb* _Strbuf, _Codecvt* _Pcvt_arg, state_type _State_arg) : _Pcvt(_Pcvt_arg), _Mystrbuf(_Strbuf), _Status(_Unused), _Nback(0) { _State = _State_arg; - _Loc = _STD locale(_Loc, _Pcvt); + _Loc = _STD locale{_Loc, _Pcvt}; } ~wbuffer_convert() noexcept override { @@ -241,13 +241,13 @@ namespace stdext { pos_type seekoff(off_type, _STD ios_base::seekdir, _STD ios_base::openmode = static_cast<_STD ios_base::openmode>( _STD ios_base::in | _STD ios_base::out)) override { // change position by _Off - return pos_type(-1); // always fail + return pos_type{off_type{-1}}; // always fail } pos_type seekpos(pos_type, _STD ios_base::openmode = static_cast<_STD ios_base::openmode>( _STD ios_base::in | _STD ios_base::out)) override { // change position to _Pos - return pos_type(-1); // always fail + return pos_type{off_type{-1}}; // always fail } private: diff --git a/stl/inc/cvt/wstring b/stl/inc/cvt/wstring index 235176bad2..02b45b89f4 100644 --- a/stl/inc/cvt/wstring +++ b/stl/inc/cvt/wstring @@ -29,7 +29,7 @@ namespace stdext { void _Init(_Codecvt* _Pcvt_arg = new _Codecvt) { // initialize the object _Pcvt = _Pcvt_arg; - _Loc = _STD locale(_Loc, _Pcvt); + _Loc = _STD locale{_Loc, _Pcvt}; _Nconv = 0; } diff --git a/stl/inc/experimental/filesystem b/stl/inc/experimental/filesystem index eee6694523..3fe48f56c4 100644 --- a/stl/inc/experimental/filesystem +++ b/stl/inc/experimental/filesystem @@ -800,27 +800,27 @@ public: template path& operator=(_InIt _First) { - return *this = path(_First); + return *this = path{_First}; } template path& operator=(const basic_string<_Elem, _Traits, _Alloc>& _Str) { - return *this = path(_Str); + return *this = path{_Str}; } template path& assign(_InIt _First, _InIt _Last) { - return *this = path(_First, _Last); + return *this = path{_First, _Last}; } template path& assign(_InIt _First) { - return *this = path(_First); + return *this = path{_First}; } template path& assign(const basic_string<_Elem, _Traits, _Alloc>& _Str) { - return *this = path(_Str); + return *this = path{_Str}; } path& operator/=(const path& _Path) { // append copy @@ -829,7 +829,7 @@ public: template path& operator/=(_InIt _First) { // append NTCTS, given iterator - return append(path(_First)._Mystr); + return append(path{_First}._Mystr); } template @@ -839,12 +839,12 @@ public: template path& append(_InIt _First, _InIt _Last) { // append NTCTS - return append(path(_First, _Last)._Mystr); + return append(path{_First, _Last}._Mystr); } template path& append(_InIt _First) { // append NTCTS - return append(path(_First)._Mystr); + return append(path{_First}._Mystr); } template @@ -890,7 +890,7 @@ public: template path& concat(_InIt _First, _InIt _Last) { // concatenate NTCTS - return concat(path(_First, _Last)._Mystr); + return concat(path{_First, _Last}._Mystr); } template @@ -900,12 +900,12 @@ public: template , int> = 0> path& concat(_InIt _First) { // concatenate NTCTS - return concat(path(_First)._Mystr); + return concat(path{_First}._Mystr); } template , int> = 0> path& concat(_Elem _Val) { // concatenate element - return concat(path(basic_string<_Elem>(1, _Val))._Mystr); + return concat(path{basic_string<_Elem>(1, _Val)}._Mystr); } template @@ -956,9 +956,9 @@ public: path& replace_extension(const path& _Newext = {}) { // replace extension with _Newext if (_Newext.empty() || _Newext.c_str()[0] == _FS_PERIOD) { - *this = parent_path() / path((stem().native() + _Newext.native())); + *this = parent_path() / path{stem().native() + _Newext.native()}; } else { - *this = parent_path() / path((stem().native() + _FS_PERIOD + _Newext.native())); + *this = parent_path() / path{stem().native() + _FS_PERIOD + _Newext.native()}; } return *this; @@ -1064,20 +1064,20 @@ public: } _NODISCARD path root_name() const { - return path(_Mystr.substr(0, _Prefix_end())); + return path{_Mystr.substr(0, _Prefix_end())}; } _NODISCARD path root_directory() const { const size_t _Idx = _Prefix_end(); if (_Idx < _Mystr.size() && _FS_ISSEP(_Mystr[_Idx])) { - return path(string_type(1, _FS_PREF)); + return path{string_type(1, _FS_PREF)}; } else { return {}; } } _NODISCARD path root_path() const { - return path(_Mystr.c_str(), _Mystr.c_str() + _Root_end()); + return path{_Mystr.c_str(), _Mystr.c_str() + _Root_end()}; } _NODISCARD path relative_path() const { @@ -1086,7 +1086,7 @@ public: ++_Idx; // skip extra '/' after root } - return path(_Mystr.substr(_Idx)); + return path{_Mystr.substr(_Idx)}; } _NODISCARD path parent_path() const { @@ -1101,14 +1101,14 @@ public: } _NODISCARD path filename() const { - return empty() ? path{} : path(*--end()); + return empty() ? path{} : path{*--end()}; } _NODISCARD path stem() const { // pick off stem (basename) in filename (leaf) before dot string_type _Str0 = filename().native(); string_type _Str1 = extension().native(); _Str0.resize(_Str0.size() - _Str1.size()); - return path(_Str0); + return path{_Str0}; } _NODISCARD path extension() const { // pick off .extension in filename (leaf), including dot @@ -1118,7 +1118,7 @@ public: || _Str.size() == 1 // only . || (_Str.size() == 2 && _Str[0] == _FS_PERIOD && _Str[1] == _FS_PERIOD) // only .. ? path{} - : path(_Str.substr(_Idx)); + : path{_Str.substr(_Idx)}; } _NODISCARD bool empty() const noexcept { @@ -1264,7 +1264,7 @@ template , int> = 0> _NODISCARD path u8path(_InIt _First, _InIt _Last) { // make path from [_First, _Last) UTF8, given iterators string _Str(_First, _Last); path::string_type _Str_out; - return path(_Path_cvt<_Char8_t, _Pchar>::_Cvt(_Str_out, _Str.c_str(), _Str.size())); + return path{_Path_cvt<_Char8_t, _Pchar>::_Cvt(_Str_out, _Str.c_str(), _Str.size())}; } template , int> = 0> @@ -1275,13 +1275,13 @@ _NODISCARD path u8path(_InIt _First) { // make path from NTBS UTF8, given iterat } path::string_type _Str_out; - return path(_Path_cvt<_Char8_t, _Pchar>::_Cvt(_Str_out, _Str.c_str(), _Str.size())); + return path{_Path_cvt<_Char8_t, _Pchar>::_Cvt(_Str_out, _Str.c_str(), _Str.size())}; } template _NODISCARD path u8path(const basic_string& _Str) { // make path from arbitrary char string UTF8 path::string_type _Str_out; - return path(_Path_cvt<_Char8_t, _Pchar>::_Cvt(_Str_out, _Str.c_str(), _Str.size())); + return path{_Path_cvt<_Char8_t, _Pchar>::_Cvt(_Str_out, _Str.c_str(), _Str.size())}; } class filesystem_error : public system_error { // base of all filesystem-error exceptions @@ -1550,10 +1550,10 @@ private: void _Form_name(typename string_type::value_type* _Filename, file_type _Ftype) { if constexpr (_Prefix_directory::value) { // set entry to _Mydirpath/_Filename - _Myentry.assign(_Mydirpath / path(_Filename), file_status(_Ftype)); + _Myentry.assign(_Mydirpath / path{_Filename}, file_status{_Ftype}); } else { // set entry to _Filename - _Myentry.assign(path(_Filename), file_status(_Ftype)); + _Myentry.assign(path{_Filename}, file_status{_Ftype}); } } @@ -2155,7 +2155,7 @@ _NODISCARD inline path current_path(error_code& _Code) { _Code = make_error_code(errc::operation_not_permitted); return {}; } - return path(_Dest); + return path{_Dest}; } inline void current_path(const path& _Path) { // set current working directory @@ -2457,7 +2457,7 @@ _NODISCARD inline path read_symlink(const path& _Path, return {}; } _Pchar _Dest[_MAX_FILESYS_NAME]; - return path(_Symlink_get(_Dest, _Path.c_str())); + return path{_Symlink_get(_Dest, _Path.c_str())}; } inline bool remove(const path& _Path) { // remove a file @@ -2613,7 +2613,7 @@ _NODISCARD inline file_status status(const path& _Path, error_code& _Code) noexc _Code.clear(); perms _Mode; const file_type _Ftype = _Stat(_Path.c_str(), &_Mode); - return file_status(_Ftype, _Mode); + return file_status{_Ftype, _Mode}; } _NODISCARD inline bool status_known(file_status _Stat) noexcept { @@ -2630,7 +2630,7 @@ _NODISCARD inline file_status symlink_status(const path& _Path, error_code& _Cod const file_type _Ftype = _Lstat(_Path.c_str(), &_Mode); _Code.clear(); - return file_status(_Ftype, _Mode); + return file_status{_Ftype, _Mode}; } _NODISCARD inline path system_complete(const path& _Path) { diff --git a/stl/inc/filesystem b/stl/inc/filesystem index e71ac1512a..ffa373bac8 100644 --- a/stl/inc/filesystem +++ b/stl/inc/filesystem @@ -381,7 +381,7 @@ namespace filesystem { // * \\server\share // We parse \\server as root-name, \ as root-directory, and share as the first element in relative-path. // Technically, Windows considers all of \\server\share the logical "root", but for purposes - // of decomposition we want those split, so that path(R"(\\server\share)").replace_filename("other_share") + // of decomposition we want those split, so that path{R"(\\server\share)"}.replace_filename("other_share") // is \\server\other_share // * \\?\device // * \??\device @@ -707,12 +707,12 @@ namespace filesystem { path& operator/=(const path& _Other) { // set *this to the path lexically resolved by _Other relative to *this // examples: - // path("cat") / "c:/dog"; // yields "c:/dog" - // path("cat") / "c:"; // yields "c:" - // path("c:") / ""; // yields "c:" - // path("c:cat") / "/dog"; // yields "c:/dog" - // path("c:cat") / "c:dog"; // yields "c:cat/dog" - // path("c:cat") / "d:dog"; // yields "d:dog" + // path{"cat"} / "c:/dog"; // yields "c:/dog" + // path{"cat"} / "c:"; // yields "c:" + // path{"c:"} / ""; // yields "c:" + // path{"c:cat"} / "/dog"; // yields "c:/dog" + // path{"c:cat"} / "c:dog"; // yields "c:cat/dog" + // path{"c:cat"} / "d:dog"; // yields "d:dog" // several places herein quote the standard, but the standard's variable p is replaced with _Other if (_Other.is_absolute()) { // if _Other.is_absolute(), then op=(_Other) @@ -772,18 +772,18 @@ namespace filesystem { template , int> = 0> path& operator/=(const _Src& _Source) { - return operator/=(path(_Source)); + return operator/=(path{_Source}); } template , int> = 0> path& append(const _Src& _Source) { - return operator/=(path(_Source)); + return operator/=(path{_Source}); } template path& append(_InIt _First, _InIt _Last) { static_assert(_Is_EcharT<_Iter_value_t<_InIt>>, "invalid value_type, see N4810 29.11.4 [fs.req]/3"); - return operator/=(path(_First, _Last)); + return operator/=(path{_First, _Last}); } path& operator+=(const path& _Added) { // concat _Added to native() @@ -816,23 +816,23 @@ namespace filesystem { template , int> = 0> path& operator+=(const _Src& _Added) { // concat _Added to native() - return operator+=(path(_Added)._Text); + return operator+=(path{_Added}._Text); } template , int> = 0> path& operator+=(const _EcharT _Added) { // concat _Added to native() - return operator+=(path(&_Added, &_Added + 1)._Text); + return operator+=(path{&_Added, &_Added + 1}._Text); } template , int> = 0> path& concat(const _Src& _Added) { // concat _Added to native() - return operator+=(path(_Added)._Text); + return operator+=(path{_Added}._Text); } template path& concat(_InIt _First, _InIt _Last) { // concat [_First, _Last) to native() static_assert(_Is_EcharT<_Iter_value_t<_InIt>>, "invalid value_type, see N4810 29.11.4 [fs.req]/3"); - return operator+=(path(_First, _Last)._Text); + return operator+=(path{_First, _Last}._Text); } void clear() noexcept { // set *this to the empty path @@ -1374,14 +1374,14 @@ namespace filesystem { _EXPORT_STD template , int> = 0> _CXX20_DEPRECATE_U8PATH _NODISCARD path u8path(const _Src& _Source) { // construct a path from UTF-8 _Source - return path(_Convert_Source_to_wide(_Source, _Utf8_conversion{})); + return path{_Convert_Source_to_wide(_Source, _Utf8_conversion{})}; } _EXPORT_STD template _CXX20_DEPRECATE_U8PATH _NODISCARD path u8path(_InIt _First, _InIt _Last) { // construct a path from UTF-8 [_First, _Last) static_assert(_Is_EcharT<_Iter_value_t<_InIt>>, "invalid value_type, see N4810 29.11.4 [fs.req]/3"); - return path(_Convert_range_to_wide(_First, _Last, _Utf8_conversion{})); + return path{_Convert_range_to_wide(_First, _Last, _Utf8_conversion{})}; } template diff --git a/stl/inc/fstream b/stl/inc/fstream index e2ff145cd5..1fc1001e6d 100644 --- a/stl/inc/fstream +++ b/stl/inc/fstream @@ -647,11 +647,11 @@ protected: if (!_Myfile || !_Endwrite() || ((_Off != 0 || _Way != ios_base::cur) && _CSTD _fseeki64(_Myfile, _Off, _Way) != 0) || _CSTD fgetpos(_Myfile, &_Fileposition) != 0) { - return pos_type(-1); // report failure + return pos_type{off_type{-1}}; // report failure } _Reset_back(); // revert from _Mychar buffer, discarding any putback - return pos_type(_State, _Fileposition); // return new position + return pos_type{_State, _Fileposition}; // return new position } pos_type __CLR_OR_THIS_CALL seekpos(pos_type _Pos, ios_base::openmode = ios_base::in | ios_base::out) override { @@ -659,12 +659,12 @@ protected: off_type _Off = static_cast(_Pos); if (!_Myfile || !_Endwrite() || _CSTD fsetpos(_Myfile, &_Off) != 0) { - return pos_type(-1); // report failure + return pos_type{off_type{-1}}; // report failure } _State = _Pos.state(); _Reset_back(); // revert from _Mychar buffer, discarding any putback - return pos_type(_State, _Off); // return new position + return pos_type{_State, _Off}; // return new position } _Mysb* __CLR_OR_THIS_CALL setbuf(_Elem* _Buffer, streamsize _Count) override { // offer _Buffer to C stream diff --git a/stl/inc/istream b/stl/inc/istream index 955d730654..c335d3501a 100644 --- a/stl/inc/istream +++ b/stl/inc/istream @@ -682,7 +682,7 @@ public: _CATCH_IO_END } - return pos_type(-1); + return pos_type{off_type{-1}}; } private: diff --git a/stl/inc/ostream b/stl/inc/ostream index 09e3db59b1..cc112046fe 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -612,7 +612,7 @@ public: _CATCH_IO_END } - return pos_type(-1); + return pos_type{off_type{-1}}; } }; diff --git a/stl/inc/spanstream b/stl/inc/spanstream index 65c3f284e3..14ff414578 100644 --- a/stl/inc/spanstream +++ b/stl/inc/spanstream @@ -116,7 +116,7 @@ protected: case ios_base::beg: // N4928 [spanbuf.virtuals]/4.1 baseoff = 0 if (static_cast(_Off) > _Buf.size()) { // negative wraparound to positive to save a compare - return pos_type(off_type(-1)); // N4928 [spanbuf.virtuals]/5 report failure + return pos_type{off_type{-1}}; // N4928 [spanbuf.virtuals]/5 report failure } break; @@ -127,40 +127,40 @@ protected: ? static_cast(_Mysb::pptr() - _Mysb::pbase()) : static_cast(_Buf.size()); if (_Off > (numeric_limits::max)() - _Baseoff) { // overflow, _Baseoff is always non-negative - return pos_type(off_type(-1)); // report failure + return pos_type{off_type{-1}}; // report failure } _Off += _Baseoff; if (static_cast(_Off) > _Buf.size()) { // negative wraparound to positive to save a compare - return pos_type(off_type(-1)); // N4928 [spanbuf.virtuals]/5 report failure + return pos_type{off_type{-1}}; // N4928 [spanbuf.virtuals]/5 report failure } break; } case ios_base::cur: if (_Sequence_in && _Sequence_out) { - return pos_type(off_type(-1)); // report failure + return pos_type{off_type{-1}}; // report failure } else if (_Sequence_in || _Sequence_out) { const off_type _Oldoff = _Sequence_in ? static_cast(_Mysb::gptr() - _Mysb::eback()) : static_cast(_Mysb::pptr() - _Mysb::pbase()); const off_type _Oldleft = static_cast(_Buf.size() - _Oldoff); if (_Off < -_Oldoff || _Off > _Oldleft) { // out of bounds - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } _Off += _Oldoff; } else { - return pos_type(off_type(-1)); // report failure + return pos_type{off_type{-1}}; // report failure } break; default: - return pos_type(off_type(-1)); // report failure + return pos_type{off_type{-1}}; // report failure } // N4928 [spanbuf.virtuals]/4: For a sequence to be positioned, if its next pointer is a null pointer and newoff // is not equal to 0, the positioning operation fails. if (_Off != 0 && ((_Sequence_in && !_Mysb::gptr()) || (_Sequence_out && !_Mysb::pptr()))) { - return pos_type(off_type(-1)); // report failure + return pos_type{off_type{-1}}; // report failure } if (_Sequence_in) { @@ -171,7 +171,7 @@ protected: _Mysb::pbump(static_cast(_Off - (_Mysb::pptr() - _Mysb::pbase()))); } - return pos_type(_Off); + return pos_type{_Off}; } pos_type seekpos(pos_type _Pos, ios_base::openmode _Which = ios_base::in | ios_base::out) override { diff --git a/stl/inc/sstream b/stl/inc/sstream index 14d4b39925..365753b94e 100644 --- a/stl/inc/sstream +++ b/stl/inc/sstream @@ -363,16 +363,16 @@ protected: _FALLTHROUGH; default: - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } if (static_cast(_Off) + _Newoff > static_cast(_Seekdist)) { - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } _Off += _Newoff; if (_Off != 0 && (((_Mode & ios_base::in) && !_Gptr_old) || ((_Mode & ios_base::out) && !_Pptr_old))) { - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } const auto _Newptr = _Seeklow + _Off; // may perform nullptr + 0 @@ -384,7 +384,7 @@ protected: _Mysb::setp(_Seeklow, _Newptr, _Mysb::epptr()); } - return pos_type(_Off); + return pos_type{_Off}; } pos_type seekpos(pos_type _Pos, ios_base::openmode _Mode = ios_base::in | ios_base::out) override { @@ -399,11 +399,11 @@ protected: const auto _Seeklow = _Mysb::eback(); const auto _Seekdist = _Seekhigh - _Seeklow; if (static_cast(_Off) > static_cast(_Seekdist)) { - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } if (_Off != 0 && (((_Mode & ios_base::in) && !_Gptr_old) || ((_Mode & ios_base::out) && !_Pptr_old))) { - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } const auto _Newptr = _Seeklow + _Off; // may perform nullptr + 0 @@ -415,7 +415,7 @@ protected: _Mysb::setp(_Seeklow, _Newptr, _Mysb::epptr()); } - return pos_type(_Off); + return pos_type{_Off}; } void _Init(const _Elem* _Ptr, _Mysize_type _Count, int _State) { diff --git a/stl/inc/streambuf b/stl/inc/streambuf index 977f91dc3f..9a9802eb0a 100644 --- a/stl/inc/streambuf +++ b/stl/inc/streambuf @@ -27,7 +27,7 @@ protected: __CLR_OR_THIS_CALL basic_streambuf(_Uninitialized) noexcept {} - __CLR_OR_THIS_CALL basic_streambuf(const basic_streambuf& _Right) : _Plocale(new locale(_Right.getloc())) { + __CLR_OR_THIS_CALL basic_streambuf(const basic_streambuf& _Right) : _Plocale(new locale{_Right.getloc()}) { _Init(); setp(_Right.pbase(), _Right.pptr(), _Right.epptr()); setg(_Right.eback(), _Right.gptr(), _Right.egptr()); @@ -361,12 +361,12 @@ protected: virtual pos_type __CLR_OR_THIS_CALL seekoff( off_type, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out) { // change position by offset, according to way and mode - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } virtual pos_type __CLR_OR_THIS_CALL seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out) { // change to specified position, according to mode - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } virtual basic_streambuf* __CLR_OR_THIS_CALL setbuf(_Elem*, streamsize) { diff --git a/stl/inc/strstream b/stl/inc/strstream index c3676e3785..7b3948f6f0 100644 --- a/stl/inc/strstream +++ b/stl/inc/strstream @@ -243,7 +243,7 @@ protected: || (_Which & ios_base::out && !pptr())) { // N4928 [depr.strstreambuf.virtuals]/15: // For a sequence to be positioned, if its next pointer // is a null pointer, the positioning operation fails. - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } const auto _Seeklow = eback(); @@ -256,14 +256,14 @@ protected: // check that _Off is in acceptable range [0, _Seekdist] if (static_cast(_Off) > static_cast(_Seekdist)) { // negative wraparound to positive to save a compare - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } break; case ios_base::end: // check that _Off is in acceptable range [-_Seekdist, 0] // is: _Off + _Seekdist in range [0, _Seekdist] if (static_cast(_Off) + _Seekdist > static_cast(_Seekdist)) { - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } _Off += _Seekdist; @@ -272,7 +272,7 @@ protected: { constexpr auto _Both = ios_base::in | ios_base::out; if ((_Which & _Both) == _Both) { // prohibited by N4928 [tab:depr.strstreambuf.seekoff.pos] - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } off_type _Oldoff; @@ -284,12 +284,12 @@ protected: _Oldoff = pptr() - pbase(); _Oldleft = _Seekhigh - pptr(); } else { - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } if (_Off < -_Oldoff // runs off beginning || _Off > _Oldleft) { // runs off end - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } _Off += _Oldoff; @@ -297,7 +297,7 @@ protected: break; default: - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } if (_Which & ios_base::in) { @@ -308,7 +308,7 @@ protected: pbump(static_cast(_Off - (pptr() - pbase()))); } - return pos_type(_Off); + return pos_type{_Off}; } pos_type __CLR_OR_THIS_CALL seekpos( @@ -319,14 +319,14 @@ protected: } if (((_Which & ios_base::in) && !gptr()) || ((_Which & ios_base::out) && !pptr())) { - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } const auto _Off = static_cast(_Sp); const auto _Seeklow = eback(); const auto _Seekdist = _Seekhigh - _Seeklow; if (_Off > _Seekdist) { - return pos_type(off_type(-1)); + return pos_type{off_type{-1}}; } if (_Which & ios_base::in) { @@ -337,7 +337,7 @@ protected: pbump(static_cast(_Off - (pptr() - pbase()))); } - return pos_type(_Off); + return pos_type{_Off}; } void __CLR_OR_THIS_CALL _Init( diff --git a/stl/inc/xlocale b/stl/inc/xlocale index 2a96cec62a..9b99562717 100644 --- a/stl/inc/xlocale +++ b/stl/inc/xlocale @@ -245,7 +245,7 @@ public: _Newimp->_Addfac(_Facptr, _Facet::id); _Newimp->_Catmask = none; _Newimp->_Name = "*"; - return locale(_Newimp); + return locale{_Newimp}; } template diff --git a/stl/inc/xlocbuf b/stl/inc/xlocbuf index 047f2bd5d3..bb33bf3da8 100644 --- a/stl/inc/xlocbuf +++ b/stl/inc/xlocbuf @@ -37,25 +37,25 @@ public: wbuffer_convert() : _State(), _Pcvt(new _Codecvt), _Mystrbuf(nullptr), _Status(_Unused), _Nback(0) { // construct without buffer pointer - _Loc = locale(_Loc, _Pcvt); + _Loc = locale{_Loc, _Pcvt}; } explicit wbuffer_convert(_Mysb* _Strbuf) : _State(), _Pcvt(new _Codecvt), _Mystrbuf(_Strbuf), _Status(_Unused), _Nback(0) { // construct with byte stream buffer pointer - _Loc = locale(_Loc, _Pcvt); + _Loc = locale{_Loc, _Pcvt}; } wbuffer_convert(_Mysb* _Strbuf, const _Codecvt* _Pcvt_arg) : _State(), _Pcvt(_Pcvt_arg), _Mystrbuf(_Strbuf), _Status(_Unused), _Nback(0) { // construct with byte stream buffer pointer and codecvt - _Loc = locale(_Loc, _Pcvt); + _Loc = locale{_Loc, _Pcvt}; } wbuffer_convert(_Mysb* _Strbuf, const _Codecvt* _Pcvt_arg, state_type _State_arg) : _State(_State_arg), _Pcvt(_Pcvt_arg), _Mystrbuf(_Strbuf), _Status(_Unused), _Nback(0) { // construct with byte stream buffer pointer, codecvt, and state - _Loc = locale(_Loc, _Pcvt); + _Loc = locale{_Loc, _Pcvt}; } ~wbuffer_convert() noexcept override { @@ -225,12 +225,12 @@ protected: pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode = static_cast(ios_base::in | ios_base::out)) override { - return pos_type(-1); // always fail + return pos_type{off_type{-1}}; // always fail } pos_type seekpos( pos_type, ios_base::openmode = static_cast(ios_base::in | ios_base::out)) override { - return pos_type(-1); // always fail + return pos_type{off_type{-1}}; // always fail } private: @@ -307,7 +307,7 @@ private: void _Init(const _Codecvt* _Pcvt_arg = new _Codecvt) { // initialize the object _State = state_type{}; _Pcvt = _Pcvt_arg; - _Loc = locale(_Loc, _Pcvt); + _Loc = locale{_Loc, _Pcvt}; _Nconv = 0; } diff --git a/stl/src/locale0.cpp b/stl/src/locale0.cpp index 2058f7b0c9..cc3e7be9bf 100644 --- a/stl/src/locale0.cpp +++ b/stl/src/locale0.cpp @@ -158,7 +158,7 @@ _MRTIMP2_PURE const locale& __CLRCALL_PURE_OR_CDECL locale::classic() { // get r _MRTIMP2_PURE locale __CLRCALL_PURE_OR_CDECL locale::empty() { // make empty transparent locale _Init(); - return locale(_Locimp::_New_Locimp(true)); + return locale{_Locimp::_New_Locimp(true)}; } _MRTIMP2_PURE locale::_Locimp* __CLRCALL_PURE_OR_CDECL locale::_Init(bool _Do_incref) { // setup global and "C" locales @@ -175,7 +175,7 @@ _MRTIMP2_PURE locale::_Locimp* __CLRCALL_PURE_OR_CDECL locale::_Init(bool _Do_in // set classic to match ptr->_Incref(); - ::new (&classic_locale) locale(ptr); + ::new (&classic_locale) locale{ptr}; #if defined(_M_CEE_PURE) locale::_Locimp::_Clocptr = ptr; #else // ^^^ _M_CEE_PURE / !_M_CEE_PURE vvv