constexpr.cc 752 B

1234567891011121314151617181920212223242526
  1. // -*- mode: c++; coding: utf-8 -*-
  2. // ra-ra/test - Constexpr checks.
  3. // (c) Daniel Llorens - 2013-2023
  4. // This library is free software; you can redistribute it and/or modify it under
  5. // the terms of the GNU Lesser General Public License as published by the Free
  6. // Software Foundation; either version 3 of the License, or (at your option) any
  7. // later version.
  8. #include <numeric>
  9. #include <iostream>
  10. #include <iterator>
  11. #include "ra/test.hh"
  12. int main()
  13. {
  14. ra::TestRecorder tr;
  15. tr.section("iota Flat constexpr");
  16. {
  17. constexpr ra::Small<int, 7> a = { 0, 1, 2, 3, 4, 5, 6 };
  18. constexpr ra::Small<int, 7> v = map([&a](int i) { return a[i]*a[i]; }, ra::iota(7));
  19. tr.test_eq(v, sqr(a));
  20. }
  21. return tr.summary();
  22. }