Commit Graph

95 Commits

Author SHA1 Message Date
Howard Hinnant
01afa5c6e4 Implement N3672, optional<T>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@189772 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-02 20:30:37 +00:00
Howard Hinnant
d179407288 is_destructible for function types was mistakenly returning true instead of false. This is true in both C++11 and C++1y, but has been clarified by the post C++11 LWG issue 2049.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@189687 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-30 19:12:42 +00:00
Howard Hinnant
de8fc6b2b1 Relax complete-type check for functions and function pointers to allow void return type. This bug was exposed by Eli Friedman's commit to clang r188324. Anywhere this version of clang ships, this libc++ fix must follow. However this fix is compatible with previous clangs, and so this libc++ doesn't need to wait for this clang.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@188413 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-14 21:28:31 +00:00
Howard Hinnant
0f678bd69e Nico Rieck: this patch series fixes visibility issues on Windows as explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@188192 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 18:38:34 +00:00
Howard Hinnant
80e19ac90f Add a check for arrays of unknown bounds to is_destructible. This fixes http://llvm.org/bugs/show_bug.cgi?id=16839
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@188080 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-09 16:53:45 +00:00
Howard Hinnant
e9df0a5c6c Nico Rieck: Currently _MSC_VER and _WIN32 are used to guard code which is
MSVC-specific, MSVCRT-specific, or Windows-specific. Because Clang can
also define _MSC_VER, and MSVCRT is not necessarily the only C runtime,
these macros should not be used interchangeably.

This patch divides all Windows-related bits into the aforementioned
categories. Two new macros are introduced:

- _LIBCPP_MSVC: Defined when compiling with MSVC. Detected using
  _MSC_VER, excluding Clang.
- _LIBCPP_MSVCRT: Defined when using the Microsoft CRT. This is the default
   when _WIN32 is defined.

This leaves _WIN32 for code using the Windows API.

This also corrects the spelling of _LIBCP_HAS_IS_BASE_OF to _LIBCPP_HAS_IS_BASE_OF.

Nico, please prepare a patch for CREDITS.TXT, thanks.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@187593 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-01 18:17:34 +00:00
Marshall Clow
01a0e90783 Make std::forward and std::move (and std::move_if_noexcept) constexpr in C++14
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@186344 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 20:46:11 +00:00
Marshall Clow
d29bb4b7c4 Implement n3545 for c++14
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185856 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-08 20:05:31 +00:00
Marshall Clow
933afa9761 Patch for N3655 (Transformation type traits) with Howard's additions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185597 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-04 00:10:01 +00:00
Howard Hinnant
6287c65a03 Remove cv qualifiers from member pointers in the __member_pointer_traits test. This was causing a const-qualified bind result to malfunction. This was a recent regression due to the new use of __member_pointer_traits in restricting the __invokable and __invoke_of tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@181935 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-15 21:49:27 +00:00
Howard Hinnant
ecc9742f27 Constrain __invoke functions more accurately. This fixes http://llvm.org/bugs/show_bug.cgi?id=15861 .
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@181377 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-07 23:40:12 +00:00
Howard Hinnant
5544f7e0c7 Somehow aligned_union got dropped through the cracks. This adds it. Did a drive-by fix of alignment_of while I was in the neighborhood.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@180036 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-22 19:37:49 +00:00
Howard Hinnant
11a50ac497 Richard Smith: It was pointed out to me off-list that libc++'s non-compiler-builtin
implementation of std::is_polymorphic does this:

template <class _Tp> struct __is_polymorphic1 : public _Tp {};

... and that g++ rejects this if _Tp has an inaccessible virtual destructor
(because __is_polymorphic1<_Tp> would have a deleted virtual destructor
overriding _Tp's non-deleted destructor). Clang was failing to reject this;
I've fixed that in r178563, but that causes libc++'s corresponding test
case to fail with both clang and gcc when using the fallback
implementation. The fallback code also incorrectly rejects final types.

The attached patch fixes the fallback implementation of is_polymorphic; we
now use dynamic_cast's detection of polymorphic class types rather than
trying to determine if adding a virtual function makes the type larger:

  enable_if<sizeof((_Tp*)dynamic_cast<const volatile
void*>(declval<_Tp*>())) != 0, ...>

Two things of note here:
* the (_Tp*) cast is necessary to work around bugs in Clang and g++ where
we otherwise don't instantiate the dynamic_cast (filed as PR15656)
* the 'const volatile' is here to treat is_polymorphic<cv T> as true for a
polymorphic class type T -- my reading of the standard suggests this is
incorrect, but it matches our builtin __is_polymorphic and gcc


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@178576 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-02 21:25:06 +00:00
Howard Hinnant
83eade6abb No functionality change at this time. I've split _LIBCPP_VISIBLE up into two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@176593 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-06 23:30:19 +00:00
Richard Smith
b2f2b68143 Implement std::is_base_of for the case where we don't have a compiler
intrinsic. This relies upon the fact that overload resolution does not check
access and ambiguity for a derived-to-base conversion. This passes all
is_base_of tests in the test suite.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@170662 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-20 04:20:28 +00:00
Howard Hinnant
4af2cf38f0 Richard Smith: This fixes a problem in std::is_constructible for incomplete types, and those types with a user-defined operator,().
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@167233 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-01 16:32:14 +00:00
Howard Hinnant
9c0df1416f Rename uses of _ and __ because these are getting stepped on by macros from other system code.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@167038 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30 19:06:59 +00:00
Howard Hinnant
33be35effe Dimitry Andric: many visibility fixes. Howard: Much appreciated. Can you send me a patch to CREDITS.TXT?
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@163862 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-14 00:39:16 +00:00
Howard Hinnant
a5160283a4 Michel Morin: My previous fix for C++03 was incomplete.
It does not consider user-defined conversions that convert an rvalue
into an lvalue and works incorrectly for types with such a conversion
operator.
For example, 

    struct foo
    {
        operator int&();
    };

 returns false_type. 
Attached a patch that fixes this problem. 
http://llvm.org/bugs/show_bug.cgi?id=13601

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162644 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-25 15:06:50 +00:00
Howard Hinnant
a0852ffbe8 Apply patches supplied by Michel Morin in http://llvm.org/bugs/show_bug.cgi?id=13601 to correct bugs in is_convertible for the case that the intrinsic __is_convertible_to is not available.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162111 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-17 17:54:11 +00:00
Howard Hinnant
e87514aa94 Patch constributed by Michel Moren in http://llvm.org/bugs/show_bug.cgi?id=13592 . Fixes is_convertible<From, To> when To is an abstract type.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161755 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-13 12:29:17 +00:00
Howard Hinnant
e41f475a44 Further tweaks on relaxing complete type checking for function.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160562 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 18:56:07 +00:00
Howard Hinnant
c425307238 Relax the complete-type checks that are happening under __invokable<Fp, Args...> to only check Fp, and not Args... . This should be sufficient to give the desired high quality diagnostics under both bind and function. And this allows a test reported by Rich E on cfe-dev to pass. Tracked by <rdar://problem/11880602>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160285 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16 16:17:34 +00:00
Howard Hinnant
2d62229b96 Fixed a bug regarding result_of reported by Sven Behne. The fix is C++11 only mainly because result_of is a variadic beast and working with variadics is just such a problem in C++03 mode. This should bring result_of up to full conformance with the C++11 spec.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159211 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-26 17:37:15 +00:00
Howard Hinnant
87073e4bfb Greatly scale back ambitions of emulating move semantics in C++03 mode. It was causing more problems than it solved. This fixes http://llvm.org/bugs/show_bug.cgi?id=12704.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@155918 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 15:37:54 +00:00
Howard Hinnant
27b4fd30ef This is an initial commit of constexpr support as proposed by Richard Smith. This by no means completes constexpr support. Indeed, it hardly scratches the surface. All it does is lay the foundation in <__config> and changes those few places in the library that are already using that foundation.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@153856 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-02 00:40:41 +00:00
Howard Hinnant
4300839b5f Hook up to the new clang __is_trivially_constructible and __is_trivially_assignable traits. Fixes r10925427 and http://llvm.org/bugs/show_bug.cgi?id=12038.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@151406 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-24 23:32:26 +00:00
Howard Hinnant
1e9f55f2d2 Use __is_polymorphic if available. This fixes http://llvm.org/bugs/show_bug.cgi?id=11983 . Patch contributed by Jonathan Sauer.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@150614 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 20:47:11 +00:00
Howard Hinnant
d7a2ad6a99 Another stab at fixing http://llvm.org/bugs/show_bug.cgi?id=12007. I earlier missed that there are two common_type definitions and corrected only one of them.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@150599 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 18:08:09 +00:00
Howard Hinnant
e5285fd6b6 Remove reference from common_type definition. It looks like a recent clang decltype implementation got fixed/improved and exposed this. Fixes http://llvm.org/bugs/show_bug.cgi?id=12007.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@150581 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 15:08:30 +00:00
Howard Hinnant
5f3f35fe64 Provide a move(const T&) overload for C++03 mode to enable moving from rvalues. This is to support proxy references. Fixes r10858112.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@150488 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-14 16:03:09 +00:00
Howard Hinnant
e814a90f74 Fix http://llvm.org/bugs/show_bug.cgi?id=11459. Patch supplied by Alberto Ganesh Barbati.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145703 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-02 20:41:47 +00:00
Howard Hinnant
9996844df0 Further macro protection by replacing _[A-Z] with _[A-Z]p
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145410 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29 18:15:50 +00:00
Howard Hinnant
8db4acad3b de-tabbify
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@142237 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 20:08:59 +00:00
Howard Hinnant
08e17472e4 Windows support by Ruben Van Boxem.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@142235 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 20:05:10 +00:00
Howard Hinnant
92a07003b2 Partial Windows port by Ruben Van Boxem
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@140328 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-22 19:10:18 +00:00
Howard Hinnant
be969d7c7d Removed unneeded boost implementation of is_base_of
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@140014 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-19 13:19:31 +00:00
Howard Hinnant
d36369d910 Fix PR10510: http://llvm.org/bugs/show_bug.cgi?id=10510
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@136232 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 18:34:06 +00:00
Sean Hunt
737a351850 Given that __underlying_type is now available in clang, implement
std::underlying_type.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135410 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-18 18:37:21 +00:00
Howard Hinnant
0949eedbd6 _STD -> _VSTD to avoid macro clash on windows
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134190 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 21:18:19 +00:00
Howard Hinnant
7604fea08c More fixes: One of my fixes to type_traits earlier today was incorrect, so that is reverted. Recently clang appears to have tightened up its definition of is_convertible and that has caused some failures in [unordered_][multi]map. I've switched to using is_constructible to restablish the desired functionality in [unordered_][multi]map. Specifically, inserting rvalues of move-only types for the keys.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@133402 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-19 21:45:00 +00:00
Howard Hinnant
d4b957820c Miscellaneous minor fixes in <type_traits>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@133401 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-19 19:12:59 +00:00
Howard Hinnant
2b1b2d40d7 Provide names for template and function parameters in forward declarations. The purpose is to aid automated documentation tools.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@133008 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 19:58:17 +00:00
Howard Hinnant
d737382dfd Turning on cxx_nullptr exposed a latent bug in is_function, causing nullptr to wrongly classify as a function. Fixed.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132406 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 17:25:11 +00:00
Howard Hinnant
1694d23e23 noexcept for <memory>. I've added a few extension noexcept to: allocator_traits<A>::deallocate, allocaate<T>::deallocate, return_temporary_buffer, and default_delete<T>::operator()(T*) const. My rationale was: If a std-dicated noexcept function needs to call another std-defined function, that called function must be noexcept. We're all a little new to noexcept, so things like this are to be expected. Also included fix for broken __is_swappable trait pointed out by Marc Glisse, thanks Marc|. And fixed a test case for is_nothrow_destructible. Destructors are now noexcept by default|
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132261 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 14:41:13 +00:00
Howard Hinnant
a5e0121b8d noexcept for <tuple>. And in the process learned that I had done it wrong for pair's swap. I needed to create an __is_nothrow_swappable<T>::value trait that was smart enought to answer false when __is_swappable<T>::value is false. Otherwise one gets compile-time errors when using pair or tuple of non-swappable types, even if you never try to swap the pair or tuple.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132204 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 19:08:18 +00:00
Howard Hinnant
e9b2c2d669 noexcept for <utility>. This included a little repair on pair, and some noexcept workarounds.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132186 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 15:04:19 +00:00
Howard Hinnant
e003ce4899 __invokable and __invoke_of now check for incomplete types and issue a compile-time diagnostic if they are used with incomplete types for anything except a return type. Note that both arguments *and* parameters are checked for completeness.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@131818 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 00:09:02 +00:00
Howard Hinnant
bd89e4b0dd This is a simplified (and superior) implementation of __invoke, __invokable and __invoke_of. It is superior in that __invoke now handles reference qualified member functions whereas the previous implementation did not. And it simply has less infrastructure in its implementation. I'm still learning how to program in C++11 (and probably will be for a long time). This change does not impact the behavior we're seeing in http://llvm.org/bugs/show_bug.cgi?id=9975
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@131761 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-20 22:02:53 +00:00
Howard Hinnant
57cff290a4 I had a giant misunderstanding of what 'synchronizes with' meant in [futures.async]/p5. This invalidated the current design of async in <future>. This is a new design, based on my new understanding, which has been confirmed on the lwg mailing list. The summary is that ~future() (and ~shared_future()) will block when they are created from within async, and the thread hasn't finished yet. As part of this work I created two new type traits: __invokable<F, Args...>::value and __invoke_of<F, Args...>::type. These are what result_of<F(Args...)> wanted to be when it grew up, but never will be. __invoke_of is carefully crafted so that it can serve as its own enable_if (type doesn't exist if the signature isn't invokable). All of this work is C++11 only.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@131639 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 15:05:04 +00:00