OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <type_traits> | 5 #include <type_traits> |
6 | 6 |
7 namespace not_blink { | 7 namespace not_blink { |
8 | 8 |
9 void function(int x) {} | 9 void function(int x) {} |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 template <int number, typename... T> | 68 template <int number, typename... T> |
69 void F() { | 69 void F() { |
70 // These are const but hacker_case so we leave them alone. | 70 // These are const but hacker_case so we leave them alone. |
71 const int maybe_a_const = sizeof...(T); | 71 const int maybe_a_const = sizeof...(T); |
72 const int is_a_const = number; | 72 const int is_a_const = number; |
73 // These are const expressions so they get a k prefix. | 73 // These are const expressions so they get a k prefix. |
74 const int maybeAConstToo = sizeof...(T); | 74 const int maybeAConstToo = sizeof...(T); |
75 const int isAConstToo = number; | 75 const int isAConstToo = number; |
76 } | 76 } |
77 | 77 |
| 78 namespace test_member_in_template { |
| 79 |
| 80 template <typename T> |
| 81 class HasAMember { |
| 82 public: |
| 83 HasAMember() {} |
| 84 HasAMember(const T&) {} |
| 85 |
| 86 void usesMember() { const int notConst = m_i; } |
| 87 void alsoUsesMember(); |
| 88 |
| 89 private: |
| 90 int m_i; |
| 91 }; |
| 92 |
| 93 template <typename T> |
| 94 void HasAMember<T>::alsoUsesMember() { |
| 95 const int notConst = m_i; |
| 96 } |
| 97 |
| 98 template <typename T> |
| 99 static void basedOnSubType(const HasAMember<T>& t) { |
| 100 const HasAMember<T> problematicNotConst(t); |
| 101 } |
| 102 |
| 103 void Run() { |
| 104 HasAMember<int>().usesMember(); |
| 105 |
| 106 basedOnSubType<int>(HasAMember<int>()); |
| 107 enum E { A }; |
| 108 basedOnSubType<E>(HasAMember<E>()); |
| 109 } |
| 110 } |
| 111 |
78 namespace test_template_arg_is_function { | 112 namespace test_template_arg_is_function { |
79 | 113 |
80 void f(int x) {} | 114 void f(int x) {} |
81 | 115 |
82 template <typename T, void g(T)> | 116 template <typename T, void g(T)> |
83 void h(T x) { | 117 void h(T x) { |
84 g(x); | 118 g(x); |
85 } | 119 } |
86 | 120 |
87 void test() { | 121 void test() { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // Need to rewrite |f| to |F| below (because this method name | 368 // Need to rewrite |f| to |F| below (because this method name |
335 // does get rewritten when processing blink::test_unnamed_arg::Class). | 369 // does get rewritten when processing blink::test_unnamed_arg::Class). |
336 // See also https://crbug.com/670434. | 370 // See also https://crbug.com/670434. |
337 output->f(123); | 371 output->f(123); |
338 } | 372 } |
339 }; | 373 }; |
340 | 374 |
341 } // namespace blink_methods_called_from_mojo_traits_are_not_rewritten | 375 } // namespace blink_methods_called_from_mojo_traits_are_not_rewritten |
342 | 376 |
343 } // namespace not_blink | 377 } // namespace not_blink |
OLD | NEW |