Three simple statements, one does not compile.
std::vector<size_t>({});
std::vector<size_t>({ 1 }); // This does not compile
std::vector<size_t>({ 1, 2 });
Only the second statement with one element in the list brings an error:
cannot convert from 'initializer-list' to 'std::vector<size_t,std::allocator<char32_t>>'
It works fine for char
, long
, int
etc., but not for size_t
. Does anybody know why and maybe there is a workaround?
Here is the complete code:
// ConsoleApplication1.cpp : main project file.
#include "stdafx.h"
#include <vector>
using namespace System;
int main(array<System::String ^> ^args)
{
std::vector<size_t>({});
std::vector<size_t>({ 1 });
std::vector<size_t>({ 1, 2 });
return 0;
}
I'm using the C++/CLI compiler from VS2013