Skip to content

Commit 8484da9

Browse files
committed
document string_view.h and optional.h
1 parent f55f08f commit 8484da9

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

src/datadog/optional.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
#pragma once
22

3-
// TODO: explain
3+
// One of the clients of this library is Envoy, a service (HTTP) proxy.
4+
//
5+
// Envoy uses Abseil as its base C++ library, and additionally builds in C++17
6+
// mode. Abseil has a build option to forward its `std::string_view` and
7+
// `std::optional` equivalents to the actual standard types when C++17 is
8+
// available.
9+
//
10+
// Envoy does not use this Abseil build option, due to incomplete support for
11+
// the C++17 standard library on iOS 11.
12+
//
13+
// As a result, Envoy forbids use of `std::string_view` and `std::optional`,
14+
// instead preferring Abseil's `absl::string_view` and `absl::optional`.
15+
//
16+
// This presents a problem for this library, since we use `std::string_view`
17+
// and `std::optional` in the exported interface, i.e. in header files.
18+
//
19+
// As a workaround, Bazel (the build tool used by Envoy) builds of this library
20+
// will define the `DD_USE_ABSEIL_FOR_ENVOY` preprocessor macro. When this
21+
// macro is defined, the library-specific `StringView` and `Optional` aliases
22+
// will refer to the Abseil types. When the macro is not defined, the
23+
// library-specific aliases will refer to the standard types.
24+
//
25+
// This file defines `datadog::tracing::Optional`, a type template that is an
26+
// alias for either `std::optional` or `absl::optional`.
427

528
#ifdef DD_USE_ABSEIL_FOR_ENVOY
629
// Abseil examples, including usage in Envoy, include Abseil headers in quoted

src/datadog/string_view.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
#pragma once
22

3-
// TODO: explain
3+
// One of the clients of this library is Envoy, a service (HTTP) proxy.
4+
//
5+
// Envoy uses Abseil as its base C++ library, and additionally builds in C++17
6+
// mode. Abseil has a build option to forward its `std::string_view` and
7+
// `std::optional` equivalents to the actual standard types when C++17 is
8+
// available.
9+
//
10+
// Envoy does not use this Abseil build option, due to incomplete support for
11+
// the C++17 standard library on iOS 11.
12+
//
13+
// As a result, Envoy forbids use of `std::string_view` and `std::optional`,
14+
// instead preferring Abseil's `absl::string_view` and `absl::optional`.
15+
//
16+
// This presents a problem for this library, since we use `std::string_view`
17+
// and `std::optional` in the exported interface, i.e. in header files.
18+
//
19+
// As a workaround, Bazel (the build tool used by Envoy) builds of this library
20+
// will define the `DD_USE_ABSEIL_FOR_ENVOY` preprocessor macro. When this
21+
// macro is defined, the library-specific `StringView` and `Optional` aliases
22+
// will refer to the Abseil types. When the macro is not defined, the
23+
// library-specific aliases will refer to the standard types.
24+
//
25+
// This file defines `datadog::tracing::StringView`, a type that is an alias
26+
// for either `std::string_view` or `absl::string_view`.
427

528
#ifdef DD_USE_ABSEIL_FOR_ENVOY
629
// Abseil examples, including usage in Envoy, include Abseil headers in quoted

0 commit comments

Comments
 (0)