1 | /* |
2 | * Copyright 2016-present Facebook, Inc. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | #include <folly/SingletonThreadLocal.h> |
18 | |
19 | #include <cstdlib> |
20 | #include <iostream> |
21 | |
22 | #include <folly/Demangle.h> |
23 | |
24 | namespace folly { |
25 | |
26 | namespace detail { |
27 | |
28 | SingletonThreadLocalBase::UniqueBase::UniqueBase( |
29 | Ref type, |
30 | Ref tag, |
31 | Ref make, |
32 | Ref tltag, |
33 | Value& value) { |
34 | if (!value.init) { |
35 | value.init = true; |
36 | value.make = &make; |
37 | value.tltag = &tltag; |
38 | } |
39 | if (*value.make == make && *value.tltag == tltag) { |
40 | return; |
41 | } |
42 | |
43 | auto const type_s = demangle(type.name()); |
44 | auto const tag_s = demangle(tag.name()); |
45 | auto const make_0_s = demangle(value.make->name()); |
46 | auto const make_1_s = demangle(make.name()); |
47 | auto const tltag_0_s = demangle(value.tltag->name()); |
48 | auto const tltag_1_s = demangle(tltag.name()); |
49 | std::ios_base::Init io_init; |
50 | std::cerr << "Overloaded folly::SingletonThreadLocal<" << type_s << ", " |
51 | << tag_s << ", ...> with differing trailing arguments:\n" |
52 | << " folly::SingletonThreadLocal<" << type_s << ", " << tag_s |
53 | << ", " << make_0_s << ", " << tltag_0_s << ">\n" |
54 | << " folly::SingletonThreadLocal<" << type_s << ", " << tag_s |
55 | << ", " << make_1_s << ", " << tltag_1_s << ">\n" ; |
56 | std::abort(); |
57 | } |
58 | |
59 | } // namespace detail |
60 | |
61 | } // namespace folly |
62 | |