summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__functional_base_03
Commit message (Collapse)AuthorAgeFilesLines
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* [libcxx] Rewrite C++03 __invoke.Eric Fiselier2015-08-261-387/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch rewrites the C++03 `__invoke` and related meta-programming. There are a number of major changes. `__invoke` in C++03 now has a fallback overload for when the invoke expression is ill-formed (similar to C++11). This means that the `__invoke_return` traits will return `__nat` when `__invoke(...)` is ill formed. This would previously cause a compile error. Bullets 1-4 of `__invoke` have been rewritten. In the old version `__invoke` had 32 overloads for bullets 1 and 2, one for each possible cv-qualified function signature with arities 0-3. 64 overloads would be needed to support member functions with varargs. Currently these overloads were fundamentally broken. An example overload looked like: ``` template <class Rp, class Tp, class T1, class A0> Rp __invoke(Rp (Tp::*pm)(A0) const, T1&, A0&) ``` Because `A0` appeared in two different deducible contexts it would have to deduce to be an exact match or the overload would be rejected. This is made even worse because `A0` appears without a reference qualifier in the member function signature and with a reference qualifier as an `__invoke` parameter. This means that only member functions that took all of their arguments by value could be matched. One possible fix would be to make the second occurrence of `A0` appear in a non-deducible context. This way any type convertible to `A0` could be passed as the first parameter. The benefit of this approach is that the signature of the member function enforces the arity and types taken by the `__invoke` signature it generates. However nothing in the `INVOKE` specification requires this behavior. My solution is to use a `__invoke_enable_if<PM_Type, Tp>` metafunction to selectively enable the `__invoke` overloads for bullets 1, 2, 3 and 4. It uses `__member_function_traits` to inspect and extract the return type and class type of the pointer to member. Using `__member_function_traits` to inspect `PM_Type` also allows us to reduce the number of `__invoke` overloads from 32 to 8 and add varargs support at the same time. Because `__invoke_enable_if` knows the exact return type of `__invoke` for bullets 1-4 we no longer need to use `decltype(__invoke(...))` to compute the return type in the `__invoke_return*` traits. This will reduce the problems caused by `#define decltype(X) __typeof__(X)` in C++03. Tests for this change have already been committed. All tests in `test/std/utilities/function.objects` now pass in C++03, previously there were 20 failures. Reviewers: K-ballo, howard.hinnant, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11553 llvm-svn: 246068
* Cleanup C++03 __invoke for Bullets 3 and 4.Eric Fiselier2015-07-281-15/+9
| | | | | | | | | | | | | | | | | | | | | | | The key changes in this patch are: 1. Remove the zero-argument overload in mem_fn. A member function must always be invoked with at least one argument, the class instance. The zero-argument operator()() in mem_fn would cause mem_fn to fail to compile when because the call to '__invoke(pm)' is not well formed. 2. Prevent evaluation of '__apply_cv<Tp, Ret>' when 'Ret' is a function type. 'Ret' is a function type whenever 'Ret Tp::*' is a pointer to member function. Attempting to add cv and ref qualifiers to a function type can cause a hard compile error. 3. Remove the dummy overload __invoke(Rp Tp::*). It was present to help work around #1. It will be replaced with a different '__invoke' overload that represents a bad call to invoke. After applying this patch the test func.wrap.func.inv/invoke.pass.cpp now passes. llvm-svn: 243370
* Get C++03 __invoke working for bullet 5 of INVOKE.Eric Fiselier2015-07-281-27/+16
| | | | | | | | | | | | | | | | | | | This patch does a couple of things to get __invoke working for free-functions and call objects. 1. Turn all uses of declval<Tp>() into declval<Tp&>(). The C++03 __invoke only supports lvalues but it will be used when the compiler supports rvalue references but not variadic templates. This change makes sure we don't generate an rvalue. 2. Call objects for bullet 5 are now passed by reference and not value. Copying the functor is incorrect. It will fail to compile for non-copyable functors and it will discard cv-qualifiers on the call object, possibly leading to the wrong function being called. I suspect that the reason the call object was originally taken by value was to support temporary call objects. However __invoke is only used internally and it is never given a temporary. llvm-svn: 243368
* Remove almost everything in <__functional_base_03>Eric Fiselier2015-07-221-367/+0
| | | | | | | | | This patch removes a large amount of duplicate code found in both <__functional_base> and <__functional_base_03>. The only code that remains in <__functional_base_03> is the C++03 implementation of __invoke and __invoke_return. llvm-svn: 242951
* Remove more commented out code. That is what version control is for.Eric Fiselier2015-07-221-236/+0
| | | | llvm-svn: 242872
* [libcxx] Fix PR 22468 - std::function<void()> does not accept ↵Eric Fiselier2015-02-101-0/+57
| | | | | | | | | | | | | | | | | | | non-void-returning functions Summary: The bug can be found here: http://llvm.org/bugs/show_bug.cgi?id=22468 `__invoke_void_return_wrapper` is needed to properly handle calling a function that returns a value but where the std::function return type is void. Without this '-Wsystem-headers' will cause `function::operator()(...)` to not compile. Reviewers: eugenis, K-ballo, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7444 llvm-svn: 228705
* Fix a problem with reference_wrapper in C++03 that was causing counting ↵Marshall Clow2014-08-041-3/+3
| | | | | | predicates to fail. Add a test to make sure it works. However, most of the reference_wrapper tests still fail in C++03 mode, due to a lack of decltype. No change there. llvm-svn: 214760
* Rename several internal templates to get rid of ___ (triple underscores) or ↵Marshall Clow2014-01-061-3/+3
| | | | | | worse, four. No functionality change. llvm-svn: 198608
* Nico Rieck: this patch series fixes visibility issues on Windows as ↵Howard Hinnant2013-08-121-1/+1
| | | | | | explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>. llvm-svn: 188192
* No functionality change at this time. I've split _LIBCPP_VISIBLE up into ↵Howard Hinnant2013-03-061-1/+1
| | | | | | two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute. llvm-svn: 176593
* Rename uses of _ and __ because these are getting stepped on by macros from ↵Howard Hinnant2012-10-301-3/+3
| | | | | | other system code. llvm-svn: 167038
* Further macro protection by replacing _[A-Z] with _[A-Z]pHoward Hinnant2011-11-291-271/+271
| | | | llvm-svn: 145410
* _STD -> _VSTD to avoid macro clash on windowsHoward Hinnant2011-06-301-8/+8
| | | | llvm-svn: 134190
* license changeHoward Hinnant2010-11-161-2/+2
| | | | llvm-svn: 119395
* Tweak to make clang blocks work with std::functional (very fragile)Howard Hinnant2010-10-031-4/+4
| | | | llvm-svn: 115461
* visibility-decoration.Howard Hinnant2010-09-211-1/+5
| | | | llvm-svn: 114451
* Fixing whitespace problemsHoward Hinnant2010-08-221-35/+34
| | | | llvm-svn: 111750
* Wiped out some non-ascii characters that snuck into the copyright.Howard Hinnant2010-05-111-1/+1
| | | | llvm-svn: 103516
* libcxx initial importHoward Hinnant2010-05-111-0/+1084
llvm-svn: 103490
OpenPOWER on IntegriCloud