2010-05-11 19:42:16 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
//
|
2019-01-19 10:56:40 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-05-11 19:42:16 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
// <string>
|
|
|
|
|
|
|
|
|
|
// reverse_iterator rend();
|
|
|
|
|
// const_reverse_iterator rend() const;
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <cassert>
|
2016-12-06 01:13:14 +00:00
|
|
|
#include <cstddef>
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2019-05-31 18:35:30 +00:00
|
|
|
#include "test_macros.h"
|
2013-11-26 20:58:02 +00:00
|
|
|
#include "min_allocator.h"
|
2013-06-28 16:59:19 +00:00
|
|
|
|
2010-05-11 19:42:16 +00:00
|
|
|
template <class S>
|
|
|
|
|
void
|
|
|
|
|
test(S s)
|
|
|
|
|
{
|
|
|
|
|
const S& cs = s;
|
|
|
|
|
typename S::reverse_iterator e = s.rend();
|
|
|
|
|
typename S::const_reverse_iterator ce = cs.rend();
|
|
|
|
|
if (s.empty())
|
|
|
|
|
{
|
|
|
|
|
assert(e == s.rbegin());
|
|
|
|
|
assert(ce == cs.rbegin());
|
|
|
|
|
}
|
2016-12-06 01:13:14 +00:00
|
|
|
assert(static_cast<std::size_t>(e - s.rbegin()) == s.size());
|
|
|
|
|
assert(static_cast<std::size_t>(ce - cs.rbegin()) == cs.size());
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-04 20:31:13 +00:00
|
|
|
int main(int, char**)
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
2013-06-28 16:59:19 +00:00
|
|
|
{
|
2010-05-11 19:42:16 +00:00
|
|
|
typedef std::string S;
|
|
|
|
|
test(S());
|
|
|
|
|
test(S("123"));
|
2013-06-28 16:59:19 +00:00
|
|
|
}
|
2016-06-14 21:31:42 +00:00
|
|
|
#if TEST_STD_VER >= 11
|
2013-06-28 16:59:19 +00:00
|
|
|
{
|
|
|
|
|
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
|
|
|
|
test(S());
|
|
|
|
|
test(S("123"));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2019-02-04 20:31:13 +00:00
|
|
|
|
|
|
|
|
return 0;
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|