diff --git a/include/Vutils.h b/include/Vutils.h index 3178e3e..5ca96a2 100644 --- a/include/Vutils.h +++ b/include/Vutils.h @@ -3339,7 +3339,9 @@ class ThreadPool // C++14 (MSVC 2015+ or MinGW 5.1+) #if (defined(_MSC_VER) && _MSVC_LANG >= 201402L) || (defined(__MINGW32__) && __cplusplus >= 201402L) #include "template/handle.tpl" -ScopedHandleT_Define(HANDLE, HANDLE, INVALID_HANDLE_VALUE, { CloseHandle(h); }); +#ifndef __MINGW32__ // `error: 'reinterpret_cast' from integer to pointer` +ScopedHandleT_Define(HANDLE, HANDLE, HANDLE(INVALID_HANDLE_VALUE), { CloseHandle(h); }); +#endif // __MINGW32__ ScopedHandleT_Define(NULL_HANDLE, HANDLE, nullptr, { CloseHandle(h); }); ScopedHandleT_Define(FILE, FILE*, nullptr, { fclose(h); }); #endif // C++14 (MSVC 2015+ or MinGW 5.1+) diff --git a/include/template/misc.tpl b/include/template/misc.tpl index 2091520..756efa5 100644 --- a/include/template/misc.tpl +++ b/include/template/misc.tpl @@ -9,8 +9,13 @@ // C++14 (MSVC 2015+ or MinGW 5.1+) #if (defined(_MSC_VER) && _MSVC_LANG >= 201402L) || (defined(__MINGW32__) && __cplusplus >= 201402L) +#include #include +/** + * print(...) (Python like) + */ + static void print_A() { std::cout << std::endl; @@ -43,6 +48,42 @@ void print_W(Head&& head, Tail&&... tail) #define print print_A #endif +/** + * _cout(....) // push all items into string-stream then use `std::cout` out to STDOUT with-in a single out + */ + +template +void __vu_cout_impl(Stream& stream) {} + +template +void __vu_cout_impl(Stream& stream, T&& t, Args&&... args) +{ + stream << std::forward(t); + __vu_cout_impl(stream, std::forward(args)...); +} + +template +void _cout_A(Args&&... args) +{ + std::stringstream ss; + __vu_cout_impl(ss, std::forward(args)...); + std::cout << ss.str(); +} + +template +void _cout_W(Args&&... args) +{ + std::wstringstream ss; + __vu_cout_impl(ss, std::forward(args)...); + std::wcout << ss.str(); +} + +#ifdef _UNICODE +#define _cout _cout_W +#else +#define _cout _cout_A +#endif + #define VU_HAS_PRINT #endif