@@ -48,6 +48,18 @@ namespace experimental {
48
48
} // namespace experimental
49
49
#endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
50
50
51
+ // clang-format off
52
+ template <class _Ty>
53
+ _INLINE_VAR constexpr bool _Is_any_path = _Is_any_of_v<_Ty
54
+ #if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
55
+ , experimental::filesystem::path
56
+ #endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
57
+ #if _HAS_CXX17
58
+ , filesystem::path
59
+ #endif // _HAS_CXX17
60
+ >;
61
+ // clang-format on
62
+
51
63
extern _CRTIMP2_PURE FILE* __CLRCALL_PURE_OR_CDECL _Fiopen(const char*, ios_base::openmode, int);
52
64
extern _CRTIMP2_PURE FILE* __CLRCALL_PURE_OR_CDECL _Fiopen(const wchar_t*, ios_base::openmode, int);
53
65
@@ -830,19 +842,10 @@ public:
830
842
const wstring& _Str, ios_base::openmode _Mode = ios_base::in, int _Prot = ios_base::_Default_open_prot)
831
843
: basic_ifstream(_Str.c_str(), _Mode, _Prot) {} // extension
832
844
833
- #if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
834
- template <class _Path_ish = experimental::filesystem::path>
835
- explicit basic_ifstream(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::in,
836
- int _Prot = ios_base::_Default_open_prot)
837
- : basic_ifstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension
838
- #endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
839
-
840
- #if _HAS_CXX17
841
- template <int = 0, class _Path_ish = filesystem::path>
842
- explicit basic_ifstream(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::in,
843
- int _Prot = ios_base::_Default_open_prot)
845
+ template <class _Ty, enable_if_t<_Is_any_path<_Ty>, int> = 0>
846
+ explicit basic_ifstream(
847
+ const _Ty& _Path, ios_base::openmode _Mode = ios_base::in, int _Prot = ios_base::_Default_open_prot)
844
848
: basic_ifstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension
845
- #endif // _HAS_CXX17
846
849
847
850
#ifdef _NATIVE_WCHAR_T_DEFINED
848
851
explicit basic_ifstream(const unsigned short* _Filename, ios_base::openmode _Mode = ios_base::in,
@@ -1023,19 +1026,10 @@ public:
1023
1026
const wstring& _Str, ios_base::openmode _Mode = ios_base::out, int _Prot = ios_base::_Default_open_prot)
1024
1027
: basic_ofstream(_Str.c_str(), _Mode, _Prot) {} // extension
1025
1028
1026
- #if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
1027
- template <class _Path_ish = experimental::filesystem::path>
1028
- explicit basic_ofstream(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::out,
1029
- int _Prot = ios_base::_Default_open_prot)
1030
- : basic_ofstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension
1031
- #endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
1032
-
1033
- #if _HAS_CXX17
1034
- template <int = 0, class _Path_ish = filesystem::path>
1035
- explicit basic_ofstream(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::out,
1036
- int _Prot = ios_base::_Default_open_prot)
1029
+ template <class _Ty, enable_if_t<_Is_any_path<_Ty>, int> = 0>
1030
+ explicit basic_ofstream(
1031
+ const _Ty& _Path, ios_base::openmode _Mode = ios_base::out, int _Prot = ios_base::_Default_open_prot)
1037
1032
: basic_ofstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension
1038
- #endif // _HAS_CXX17
1039
1033
1040
1034
#ifdef _NATIVE_WCHAR_T_DEFINED
1041
1035
explicit basic_ofstream(const unsigned short* _Filename, ios_base::openmode _Mode = ios_base::out,
@@ -1221,19 +1215,10 @@ public:
1221
1215
int _Prot = ios_base::_Default_open_prot)
1222
1216
: basic_fstream(_Str.c_str(), _Mode, _Prot) {} // extension
1223
1217
1224
- #if _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
1225
- template <class _Path_ish = experimental::filesystem::path>
1226
- explicit basic_fstream(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::in | ios_base::out,
1218
+ template <class _Ty, enable_if_t<_Is_any_path<_Ty>, int> = 0>
1219
+ explicit basic_fstream(const _Ty& _Path, ios_base::openmode _Mode = ios_base::in | ios_base::out,
1227
1220
int _Prot = ios_base::_Default_open_prot)
1228
1221
: basic_fstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension
1229
- #endif // _FSTREAM_SUPPORTS_EXPERIMENTAL_FILESYSTEM
1230
-
1231
- #if _HAS_CXX17
1232
- template <int = 0, class _Path_ish = filesystem::path>
1233
- explicit basic_fstream(const _Identity_t<_Path_ish>& _Path, ios_base::openmode _Mode = ios_base::in | ios_base::out,
1234
- int _Prot = ios_base::_Default_open_prot)
1235
- : basic_fstream(_Path.c_str(), _Mode, _Prot) {} // _Prot is an extension
1236
- #endif // _HAS_CXX17
1237
1222
1238
1223
#ifdef _NATIVE_WCHAR_T_DEFINED
1239
1224
explicit basic_fstream(const unsigned short* _Filename, ios_base::openmode _Mode = ios_base::in | ios_base::out,
0 commit comments