minix/external/bsd/libc++/dist/libcxx/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
Lionel Sambuc 4684ddb6aa LLVM Minix changes
- import libcxx
 - reduce targets to the one when compiled as a tools

Change-Id: Iabb8427f80ff8e89463559a28bcb8b4f2bdbc496
2014-07-28 17:05:59 +02:00

59 lines
1.4 KiB
C++

//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <initializer_list>
// template<class E> const E* begin(initializer_list<E> il);
#include <initializer_list>
#include <cassert>
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
struct A
{
A(std::initializer_list<int> il)
{
const int* b = begin(il);
const int* e = end(il);
assert(il.size() == 3);
assert(e - b == il.size());
assert(*b++ == 3);
assert(*b++ == 2);
assert(*b++ == 1);
}
};
#if _LIBCPP_STD_VER > 11
struct B
{
constexpr B(std::initializer_list<int> il)
{
const int* b = begin(il);
const int* e = end(il);
assert(il.size() == 3);
assert(e - b == il.size());
assert(*b++ == 3);
assert(*b++ == 2);
assert(*b++ == 1);
}
};
#endif // _LIBCPP_STD_VER > 11
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
A test1 = {3, 2, 1};
#endif
#if _LIBCPP_STD_VER > 11
constexpr B test2 = {3, 2, 1};
#endif // _LIBCPP_STD_VER > 11
}