back_const.pass.cpp 704 B

123456789101112131415161718192021222324252627282930
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <queue>
  9. // const_reference back() const;
  10. #include <queue>
  11. #include <cassert>
  12. #include "test_macros.h"
  13. int main(int, char**)
  14. {
  15. std::queue<int> q;
  16. assert(q.size() == 0);
  17. q.push(1);
  18. q.push(2);
  19. q.push(3);
  20. const std::queue<int>& cqr = q;
  21. const int& cir = cqr.back();
  22. assert(cir == 3);
  23. return 0;
  24. }