How can I cin and cout some unicode text?

I had a similar problem in the past, in my case imbue and sync_with_stdio did the trick. Try this: #include <iostream> #include <locale> #include <string> using namespace std; int main() { ios_base::sync_with_stdio(false); wcin.imbue(locale(“en_US.UTF-8”)); wcout.imbue(locale(“en_US.UTF-8″)); wstring s; wstring t(L” la PolynĂ©sie française”); wcin >> s; wcout << s << t << endl; return 0; }

Getting an array of bytes out of Windows::Storage::Streams::IBuffer

You can use IBufferByteAccess, through exotic COM casts: byte* GetPointerToPixelData(IBuffer^ buffer) { // Cast to Object^, then to its underlying IInspectable interface. Object^ obj = buffer; ComPtr<IInspectable> insp(reinterpret_cast<IInspectable*>(obj)); // Query the IBufferByteAccess interface. ComPtr<IBufferByteAccess> bufferByteAccess; ThrowIfFailed(insp.As(&bufferByteAccess)); // Retrieve the buffer data. byte* pixels = nullptr; ThrowIfFailed(bufferByteAccess->Buffer(&pixels)); return pixels; } Code sample copied from

How to tell if a type is an instance of a specific template class?

Here’s an option: #include <iostream> #include <type_traits> #include <string> template <class, template <class> class> struct is_instance : public std::false_type {}; template <class T, template <class> class U> struct is_instance<U<T>, U> : public std::true_type {}; template <class> class Second {}; int main() { using A = Second<int>; using B = Second<std::string>; using C = float; std::cout … Read more

Is char default-promoted?

First, default argument promotions If the expression that denotes the called function has a type that does not include a prototype, the integer promotions are performed on each argument, and arguments that have type float are promoted to double. These are called the default argument promotions. Now for integer promotions: The following may … Read more

Overload resolution with std::function

In C++11… Let’s take a look at the specification of the constructor template of std::function (which takes any Callable): [func.wrap.func.con]/7-10 template<class F> function(F f); template <class F, class A> function(allocator_arg_t, const A& a, F f); 7 Requires: F shall be CopyConstructible. f shall be Callable ( for argument types ArgTypes and return type R. The … Read more