Kudu C++ client API
Loading...
Searching...
No Matches
shared_ptr.h
Go to the documentation of this file.
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#ifndef KUDU_CLIENT_SHARED_PTR_H
19#define KUDU_CLIENT_SHARED_PTR_H
20
36
37// This include is not used directly, but we need to include some C++ header in
38// order to ensure the _LIBCPP_VERSION macro is defined appropriately.
39#include <string>
40
41#if defined(_LIBCPP_VERSION)
42
43// TODO(adar): our IWYU runs with libc++ and misbehaves with this header:
44//
45// 1. All inclusions must append "// IWYU pragma: keep" otherwise IWYU removes them.
46// 2. IWYU adds <memory> to every file that includes this header.
47//
48// In theory, the second problem can be addressed by adding
49// "// IWYU pragma: export" to the inclusion of <memory> just below. However,
50// that actually inverts the effect: IWYU removes <memory> from every file that
51// includes this header. This is unsafe because if we're doing a regular Kudu
52// build, this header includes <tr1/memory>, leaving the source file without any
53// inclusion of <memory> and unable to satisfy references to e.g. std::unique_ptr.
54//
55// There must be a way to convince IWYU that the classes in kudu::client::sp are
56// "real" and not just aliases of std classes. One way to do that would be to
57// insert complete copies of those classes just for IWYU, but that seems like overkill.
58#include <memory>
59
60namespace kudu {
61namespace client {
62namespace sp {
63 using std::shared_ptr;
64 using std::weak_ptr;
65 using std::enable_shared_from_this;
66}
67}
68}
69
70#else
71#include <tr1/memory>
72
73namespace kudu {
74namespace client {
75namespace sp {
76 using std::tr1::shared_ptr;
77 using std::tr1::weak_ptr;
78 using std::tr1::enable_shared_from_this;
79}
80}
81}
82#endif
83
84#endif // define KUDU_CLIENT_SHARED_PTR_H