Changeset View
Changeset View
Standalone View
Standalone View
test/std/containers/sequences/array/begin.pass.cpp
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// The LLVM Compiler Infrastructure | // The LLVM Compiler Infrastructure | ||||
// | // | ||||
// This file is dual licensed under the MIT and the University of Illinois Open | // This file is dual licensed under the MIT and the University of Illinois Open | ||||
// Source Licenses. See LICENSE.TXT for details. | // Source Licenses. See LICENSE.TXT for details. | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// <array> | // <array> | ||||
// iterator begin(); | // iterator begin(); | ||||
#include <array> | #include <array> | ||||
#include <cassert> | #include <cassert> | ||||
#include "test_macros.h" | |||||
// std::array is explicitly allowed to be initialized with A a = { init-list };. | // std::array is explicitly allowed to be initialized with A a = { init-list };. | ||||
// Disable the missing braces warning for this reason. | // Disable the missing braces warning for this reason. | ||||
#include "disable_missing_braces_warning.h" | #include "disable_missing_braces_warning.h" | ||||
struct NoDefault { | struct NoDefault { | ||||
NoDefault(int) {} | NoDefault(int) {} | ||||
}; | }; | ||||
Show All 10 Lines | int main() | ||||
assert(&*i == c.data()); | assert(&*i == c.data()); | ||||
*i = 5.5; | *i = 5.5; | ||||
assert(c[0] == 5.5); | assert(c[0] == 5.5); | ||||
} | } | ||||
{ | { | ||||
typedef NoDefault T; | typedef NoDefault T; | ||||
typedef std::array<T, 0> C; | typedef std::array<T, 0> C; | ||||
C c = {}; | C c = {}; | ||||
assert(c.begin() == c.end()); | C::iterator ib, ie; | ||||
ib = c.begin(); | |||||
ie = c.end(); | |||||
assert(ib == ie); | |||||
LIBCPP_ASSERT(ib != nullptr); | |||||
ldionne: Comparing the iterator to `nullptr` assumes the iterators to be pointers, which I don't think… | |||||
Not Done ReplyInline ActionsThis doesn't compile because you're missing an include of "test_macros.h". Please make a habit of running the tests before submitting a review. ldionne: This doesn't compile because you're missing an include of `"test_macros.h"`. Please make a… | |||||
LIBCPP_ASSERT(ie != nullptr); | |||||
} | } | ||||
} | } |
Comparing the iterator to nullptr assumes the iterators to be pointers, which I don't think is required. They're only required to be contiguous iterators.