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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 template <int number, typename... T> | 69 template <int number, typename... T> |
70 void F() { | 70 void F() { |
71 // These are const but hacker_case so we leave them alone. | 71 // These are const but hacker_case so we leave them alone. |
72 const int maybe_a_const = sizeof...(T); | 72 const int maybe_a_const = sizeof...(T); |
73 const int is_a_const = number; | 73 const int is_a_const = number; |
74 // These are const expressions so they get a k prefix. | 74 // These are const expressions so they get a k prefix. |
75 const int kMaybeAConstToo = sizeof...(T); | 75 const int kMaybeAConstToo = sizeof...(T); |
76 const int kIsAConstToo = number; | 76 const int kIsAConstToo = number; |
77 } | 77 } |
78 | 78 |
| 79 namespace test_member_in_template { |
| 80 |
| 81 template <typename T> |
| 82 class HasAMember { |
| 83 public: |
| 84 HasAMember() {} |
| 85 HasAMember(const T&) {} |
| 86 |
| 87 void UsesMember() { const int not_const = i_; } |
| 88 void AlsoUsesMember(); |
| 89 |
| 90 private: |
| 91 int i_; |
| 92 }; |
| 93 |
| 94 template <typename T> |
| 95 void HasAMember<T>::AlsoUsesMember() { |
| 96 const int not_const = i_; |
| 97 } |
| 98 |
| 99 template <typename T> |
| 100 static void BasedOnSubType(const HasAMember<T>& t) { |
| 101 const HasAMember<T> problematic_not_const(t); |
| 102 } |
| 103 |
| 104 void Run() { |
| 105 HasAMember<int>().UsesMember(); |
| 106 |
| 107 BasedOnSubType<int>(HasAMember<int>()); |
| 108 enum E { A }; |
| 109 BasedOnSubType<E>(HasAMember<E>()); |
| 110 } |
| 111 } |
| 112 |
79 namespace test_template_arg_is_function { | 113 namespace test_template_arg_is_function { |
80 | 114 |
81 void F(int x) {} | 115 void F(int x) {} |
82 | 116 |
83 template <typename T, void g(T)> | 117 template <typename T, void g(T)> |
84 void H(T x) { | 118 void H(T x) { |
85 g(x); | 119 g(x); |
86 } | 120 } |
87 | 121 |
88 void Test() { | 122 void Test() { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // Need to rewrite |f| to |F| below (because this method name | 369 // Need to rewrite |f| to |F| below (because this method name |
336 // does get rewritten when processing blink::test_unnamed_arg::Class). | 370 // does get rewritten when processing blink::test_unnamed_arg::Class). |
337 // See also https://crbug.com/670434. | 371 // See also https://crbug.com/670434. |
338 output->F(123); | 372 output->F(123); |
339 } | 373 } |
340 }; | 374 }; |
341 | 375 |
342 } // namespace blink_methods_called_from_mojo_traits_are_not_rewritten | 376 } // namespace blink_methods_called_from_mojo_traits_are_not_rewritten |
343 | 377 |
344 } // namespace not_blink | 378 } // namespace not_blink |
OLD | NEW |