123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #ifndef ABSL_STRINGS_INTERNAL_STRING_CONSTANT_H_
- #define ABSL_STRINGS_INTERNAL_STRING_CONSTANT_H_
- #include "absl/meta/type_traits.h"
- #include "absl/strings/string_view.h"
- namespace absl {
- ABSL_NAMESPACE_BEGIN
- namespace strings_internal {
- template <typename T>
- struct StringConstant {
- private:
- static constexpr bool TryConstexprEval(absl::string_view view) {
- return view.empty() || 2 * view[0] != 1;
- }
- public:
- static constexpr absl::string_view value = T{}();
- constexpr absl::string_view operator()() const { return value; }
-
-
- static_assert(TryConstexprEval(value),
- "The input string_view must point to constant data.");
- };
- #ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
- template <typename T>
- constexpr absl::string_view StringConstant<T>::value;
- #endif
- template <typename T>
- constexpr StringConstant<T> MakeStringConstant(T) {
- return {};
- }
- }
- ABSL_NAMESPACE_END
- }
- #endif
|