[libcxx][functional][modular] splices <functional> into modular headers

Differential Revision: https://reviews.llvm.org/D104942

NOKEYCHECK=True
GitOrigin-RevId: 050b064f15ee56ee0b42c9b957a3dd0f32532394
diff --git a/include/experimental/__memory b/include/experimental/__memory
index 4cf8978..b38b664 100644
--- a/include/experimental/__memory
+++ b/include/experimental/__memory
@@ -10,6 +10,8 @@
 #ifndef _LIBCPP_EXPERIMENTAL___MEMORY
 #define _LIBCPP_EXPERIMENTAL___MEMORY
 
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
 #include <experimental/__config>
 #include <experimental/utility> // for erased_type
 #include <__functional_base>
@@ -73,12 +75,35 @@
     >
 {};
 
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
+{
+    new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
+}
+
+// FIXME: This should have a version which takes a non-const alloc.
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
+{
+    new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
+}
+
+// FIXME: This should have a version which takes a non-const alloc.
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
+{
+    new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
+}
+
 template <class _Tp, class _Alloc, class ..._Args>
 inline _LIBCPP_INLINE_VISIBILITY
 void __lfts_user_alloc_construct(
     _Tp * __store, const _Alloc & __a, _Args &&... __args)
 {
-    _VSTD::__user_alloc_construct_impl(
+    ::std::experimental::fundamentals_v1::__user_alloc_construct_impl(
         typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type()
        , __store, __a, _VSTD::forward<_Args>(__args)...
        );
diff --git a/include/experimental/functional b/include/experimental/functional
index e189620..e3220e1 100644
--- a/include/experimental/functional
+++ b/include/experimental/functional
@@ -86,6 +86,7 @@
 
 */
 
+#include <__memory/uses_allocator.h>
 #include <experimental/__config>
 #include <functional>
 #include <algorithm>