| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target c++14 } */ |
| 3 |
/* { dg-options "-O3 -fdump-tree-ldist-optimized" } */ |
| 4 |
/* { dg-skip-if "requires hosted libstdc++ for cstring" { ! hostedlib } } */ |
| 5 |
|
| 6 |
#include <stddef.h> |
| 7 |
#include <cstring> |
| 8 |
#include <experimental/string_view> |
| 9 |
|
| 10 |
using string_view = std::experimental::string_view; |
| 11 |
|
| 12 |
class Foo { |
| 13 |
constexpr static size_t Length = 9; |
| 14 |
char ascii_[Length]; |
| 15 |
public: |
| 16 |
Foo(); |
| 17 |
string_view view() const { |
| 18 |
return string_view(ascii_, Length); |
| 19 |
} |
| 20 |
}; |
| 21 |
|
| 22 |
void testWithLoopValue(const Foo foo, size_t ptr, char *buf_) { |
| 23 |
for (auto c : foo.view()) |
| 24 |
buf_[ptr++] = c; |
| 25 |
} |
| 26 |
|
| 27 |
/* { dg-final { scan-tree-dump "split to 0 loops and 1 library calls" "ldist" } } */ |