Skip to content

[libc] move in_place_t in utility #65623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions libc/src/__support/CPP/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
namespace __llvm_libc {
namespace cpp {

// Trivial in_place_t struct.
struct in_place_t {
LIBC_INLINE constexpr explicit in_place_t() = default;
};

// Trivial nullopt_t struct.
struct nullopt_t {
LIBC_INLINE constexpr explicit nullopt_t() = default;
Expand All @@ -29,9 +24,6 @@ struct nullopt_t {
// nullopt that can be used and returned.
LIBC_INLINE_VAR constexpr nullopt_t nullopt{};

// in_place that can be used in the constructor.
LIBC_INLINE_VAR constexpr in_place_t in_place{};

// This is very simple implementation of the std::optional class. It makes
// several assumptions that the underlying type is trivially constructable,
// copyable, or movable.
Expand Down
1 change: 1 addition & 0 deletions libc/src/__support/CPP/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "src/__support/CPP/utility/declval.h"
#include "src/__support/CPP/utility/forward.h"
#include "src/__support/CPP/utility/in_place.h"
#include "src/__support/CPP/utility/integer_sequence.h"
#include "src/__support/CPP/utility/move.h"

Expand Down
36 changes: 36 additions & 0 deletions libc/src/__support/CPP/utility/in_place.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===-- in_place utility ----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_IN_PLACE_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_IN_PLACE_H

#include "src/__support/macros/attributes.h"

#include <stddef.h> // size_t

namespace __llvm_libc::cpp {

// in_place
struct in_place_t {
explicit in_place_t() = default;
};
LIBC_INLINE_VAR constexpr in_place_t in_place{};

template <class T> struct in_place_type_t {
explicit in_place_type_t() = default;
};
template <class T> LIBC_INLINE_VAR constexpr in_place_type_t<T> in_place_type{};

template <size_t I> struct in_place_index_t {
explicit in_place_index_t() = default;
};
template <size_t I>
LIBC_INLINE_VAR constexpr in_place_index_t<I> in_place_index{};

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_IN_PLACE_H
1 change: 1 addition & 0 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ libc_support_library(
"src/__support/CPP/utility.h",
"src/__support/CPP/utility/declval.h",
"src/__support/CPP/utility/forward.h",
"src/__support/CPP/utility/in_place.h",
"src/__support/CPP/utility/integer_sequence.h",
"src/__support/CPP/utility/move.h",
],
Expand Down