|
1 | 1 | #pragma once |
2 | 2 |
|
3 | | -int fnOverload(int i, int j) |
| 3 | +// Template bindings include this header in multiple translation units. |
| 4 | +inline int bindingOrder(int value) { return 1; } |
| 5 | +inline int bindingOrder(long value) { return 2; } |
| 6 | + |
| 7 | +inline int bindingOrderUnchanged(int value) { return 1; } |
| 8 | +inline int bindingOrderUnchanged(long value) { return 2; } |
| 9 | + |
| 10 | +inline int bindingOrderLater(int value) { return 1; } |
| 11 | +inline int bindingOrderLater(long value) { return 2; } |
| 12 | + |
| 13 | +inline int bindingOrderTied(int value, int skip = 0) { return 1; } |
| 14 | +inline int bindingOrderTied(long value) { return 2; } |
| 15 | +inline int bindingOrderTied(long long value, int skip = 0) { return 3; } |
| 16 | + |
| 17 | +inline int bindingOrderInherited(int value, int subset = 0, int inherited = 0) { return 1; } |
| 18 | +inline int bindingOrderInherited(long value, int subset = 0, int inherited = 0) { return 2; } |
| 19 | +inline int bindingOrderInherited(long long value, int subset = 0) { return 3; } |
| 20 | +inline int bindingOrderInherited(short value) { return 4; } |
| 21 | + |
| 22 | +struct BindingOrder { |
| 23 | + BindingOrder(int value) : selected(1) {} |
| 24 | + BindingOrder(long value) : selected(2) {} |
| 25 | + virtual ~BindingOrder() = default; |
| 26 | + |
| 27 | + int choose(int value) { return 1; } |
| 28 | + int choose(long value) { return 2; } |
| 29 | + int unchanged(int value) { return 1; } |
| 30 | + int unchanged(long value) { return 2; } |
| 31 | + static int chooseStatic(int value) { return 1; } |
| 32 | + static int chooseStatic(long value) { return 2; } |
| 33 | + |
| 34 | + int later(int value) { return 1; } |
| 35 | + int later(long value) { return 2; } |
| 36 | + |
| 37 | + int tied(int value, int skip = 0) { return 1; } |
| 38 | + int tied(long value) { return 2; } |
| 39 | + int tied(long long value, int skip = 0) { return 3; } |
| 40 | + |
| 41 | + int inherited(int value, int subset = 0, int inherited = 0) { return 1; } |
| 42 | + int inherited(long value, int subset = 0, int inherited = 0) { return 2; } |
| 43 | + int inherited(long long value, int subset = 0) { return 3; } |
| 44 | + int inherited(short value) { return 4; } |
| 45 | + |
| 46 | + int selected; |
| 47 | + |
| 48 | +protected: |
| 49 | + int chooseProtected(int value) { return 1; } |
| 50 | + int chooseProtected(long value) { return 2; } |
| 51 | + |
| 52 | + // Declared before public overloads to test the existing public-first order. |
| 53 | + int mixedUnchanged(long value) { return 2; } |
| 54 | + int mixedPrioritized(long value) { return 2; } |
| 55 | + |
| 56 | +public: |
| 57 | + int mixedUnchanged(int value) { return 1; } |
| 58 | + int mixedPrioritized(int value) { return 1; } |
| 59 | +}; |
| 60 | + |
| 61 | +template <typename T> |
| 62 | +struct BindingOrderTemplate { |
| 63 | + int choose(T value) { return 1; } |
| 64 | + int choose(long value) { return 2; } |
| 65 | +}; |
| 66 | + |
| 67 | +inline int fnOverload(int i, int j) |
4 | 68 | { |
5 | 69 | return j; |
6 | 70 | } |
7 | 71 |
|
8 | | -int fnOverload(int i) |
| 72 | +inline int fnOverload(int i) |
9 | 73 | { |
10 | 74 | return i; |
11 | 75 | } |
|
0 commit comments