Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move FOLLY_DEFINE_CPO to folly/lang/CustomizationPoint.h
Summary: [Folly] Move `FOLLY_DEFINE_CPO` to `folly/lang/CustomizationPoint.h`. And move `StaticConst` to top-level `folly` namespace and into `folly/lang/`. And Americanize the spellings of words in the comments. Reviewed By: ericniebler, lewissbaker Differential Revision: D14402315 fbshipit-source-id: e13dbc9d471ee73ba0a289d375c235734334b920
- Loading branch information
1 parent
4008ab2
commit ca91b0e
Showing
5 changed files
with
50 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2019-present Facebook, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <folly/lang/StaticConst.h> | ||
|
||
// FOLLY_DEFINE_CPO | ||
// | ||
// Helper for portably defining customization-point objects (CPOs). | ||
// | ||
// The customization-point object must be placed in a nested namespace to avoid | ||
// potential conflicts with customizations defined as friend-functions of types | ||
// defined in the same namespace as the CPO. | ||
// | ||
// In C++17 and later the object may be defined using 'inline constexpr' to | ||
// avoid ODR issues. However, prior to that a helper template is required to | ||
// ensure that there is only a single instance of the CPO created and then a | ||
// named reference in an anonymous namespace is required to avoid duplicate | ||
// symbol definitions. | ||
#if __cpp_inline_variables >= 201606L | ||
#define FOLLY_DEFINE_CPO(Type, Name) \ | ||
namespace folly_cpo__ { \ | ||
inline constexpr Type Name{}; \ | ||
} \ | ||
using namespace folly_cpo__; | ||
#else | ||
#define FOLLY_DEFINE_CPO(Type, Name) \ | ||
namespace { \ | ||
constexpr auto& Name = ::folly::StaticConst<Type>::value; \ | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters