Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #ifdef __cpp_concepts
- # define SCAN_REQUIRES(S, T) requires requires(T t) { S >> t; }
- #else
- # define SCAN_REQUIRES(S, T)
- #endif
- namespace impl {
- template<typename CharT>
- struct scan_fn;
- template<>
- struct scan_fn<char> {
- template<typename T> SCAN_REQUIRES(std::cin, T)
- operator T() const {
- T t;
- std::cin >> t;
- return t;
- }
- };
- template<>
- struct scan_fn<wchar_t> {
- template<typename T> SCAN_REQUIRES(std::wcin, T)
- operator T() const {
- T t;
- std::wcin >> t;
- return t;
- }
- };
- }
- inline constexpr impl::scan_fn<char> scan;
- inline constexpr impl::scan_fn<wchar_t> wscan;
- #undef SCAN_REQUIRES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement