-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (36 loc) · 669 Bytes
/
Copy pathmain.cpp
File metadata and controls
47 lines (36 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Andreas Fertig.
// SPDX-License-Identifier: MIT
#if __has_include(<ranges>)
# include <iostream>
# include <ranges>
struct Container {}; // #A Container without begin
int* begin(Container) // #B Free-function begin for Container
{
std::cout << "begin(Container)\n";
return nullptr;
}
struct OtherContainer { // #C Container with begin
int* begin()
{
std::cout << "OtherContainer::begin()\n";
return nullptr;
}
};
void Use(auto& c)
{
// #G Use ranges
std::ranges::begin(c);
}
int main()
{
Container c{};
Use(c);
OtherContainer oc{};
Use(oc);
}
#else
int main()
{
# pragma message("not supported")
}
#endif