summaryrefslogtreecommitdiffstats
path: root/libcxx/include/functional
Commit message (Collapse)AuthorAgeFilesLines
...
* Add C++17 std::not_fn negator.Eric Fiselier2016-06-021-2/+47
| | | | | | | | | | | | | | | Summary: Exactly what it sounds like. I plan to commit this in a couple of days assuming no objections. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20799 llvm-svn: 271464
* Add hash specializations for __int128_t. Fixes LWG issue 2119Eric Fiselier2016-04-181-0/+16
| | | | llvm-svn: 266587
* Fix invalid casts in <functional>.Evgeniy Stepanov2016-02-101-29/+31
| | | | | | | | | | | | | static_cast of a pointer to object before the start of the object's lifetime has undefined behavior. This code triggers CFI warnings. This change replaces C-style casts with reinterpret_cast, which is fine per the standard, add applies an attribute to silence CFI (which barks on reinterpret_cast, too). llvm-svn: 260441
* Implement LWG#2385; remove the allocator-aware std::function::assign call. ↵Marshall Clow2016-01-251-1/+4
| | | | | | It was useless, and didn't actually *do anything* with the allocator. Now it's gone. On the off chance that someone is mistakenly calling it, it's only gone in C++1z llvm-svn: 258697
* Fix LWG#2489: mem_fn() should be noexceptMarshall Clow2015-10-251-2/+2
| | | | llvm-svn: 251257
* [libcxx] Rewrite C++03 __invoke.Eric Fiselier2015-08-261-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [libcxx] Fix PR23589: std::function doesn't recognize null pointer to ↵Eric Fiselier2015-08-181-24/+18
| | | | | | | | | | | | | | | | | | | | varargs function. Summary: This patch fixes __not_null's detection of nullptr by breaking it down into 4 cases. 1. `__not_null(Tp const&)`: Default case. Tp is not null. 2. `__not_null(Tp* __ptr);` Case for pointers to functions. 3. `__not_null(_Ret _Class::* __ptr);` Case for pointers to members. 4. `__not_null(function<Tp> const&);`: Cases for other std::functions. Reviewers: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11111 llvm-svn: 245335
* Cleanup C++03 __invoke for Bullets 3 and 4.Eric Fiselier2015-07-281-4/+0
| | | | | | | | | | | | | | | | | | | | | | | 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
* Merge C++03 and C++11 implementations of mem_fn and __mem_fn.Eric Fiselier2015-07-221-20/+35
| | | | | | | | | | | | | | | | | The implementation of mem_fn doesn't actually require any C++11 support. For some reason there were 17 overloads for mem_fn in C++03 when only one is needed. This patch removes the extra overloads and uses the same implementation of mem_fn in C++03 and C++11. __mem_fn does require variadics to implement the call operator. Instead of having two entirely different implementations of the __mem_fn struct, this patch uses the same __mem_fn struct but provides different call operators when variadics are not available. The only thing left in <__functional_03> is the C++03 implementation of std::function. llvm-svn: 242959
* Cleanup <__functional_03>Eric Fiselier2015-07-221-6/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | <__functional_03> provides the C++03 definitions for std::memfun and std::function. However the interaction between <functional> and <__functional_03> is ugly and duplicates code needlessly. This patch cleans up how the two headers work together. The major changes are: - Provide placeholders, is_bind_expression and is_placeholder in <functional> for both C++03 and C++11. - Provide bad_function_call, function fwd decl, __maybe_derive_from_unary_function and __maybe_derive_from_binary_function in <functional> for both C++03 and C++11. - Move the <__functional_03> include to the bottom of <functional>. This makes it easier to see how <__functional_03> interacts with <functional> - Remove a commented out implementation of bind in C++03. It's never going to get implemented. - Mark almost all std::bind tests as unsupported in C++03. std::is_placeholder works in C++03 and C++11. std::is_bind_expression is provided in C++03 but always returns false. llvm-svn: 242870
* Enable and fix warnings during the build.Eric Fiselier2015-07-181-10/+10
| | | | | | | | | | | | | | | | | Although CMake adds warning flags, they are ignored in the libc++ headers because the headers '#pragma system header' themselves. This patch disables the system header pragma when building libc++ and fixes the warnings that arose. The warnings fixed were: 1. <memory> - anonymous structs are a GNU extension 2. <functional> - anonymous structs are a GNU extension. 3. <__hash_table> - Embedded preprocessor directives have undefined behavior. 4. <string> - Definition is missing noexcept from declaration. 5. <__std_stream> - Unused variable. llvm-svn: 242623
* Implement n4169 - Add invoke function templateEric Fiselier2015-07-141-0/+9
| | | | llvm-svn: 242195
* [libcxx] LWG2420 bits for bind<void> - Patch from K-BalloEric Fiselier2015-07-101-4/+6
| | | | | | | Implemented LWG2420 bits for bind<void> Review: http://reviews.llvm.org/D10997 llvm-svn: 241967
* Rename internal trait that used non-reserved name.Eric Fiselier2015-05-191-4/+4
| | | | llvm-svn: 237737
* In many places, there was an #ifdef/#else block that selected one of two ↵Marshall Clow2015-04-071-21/+3
| | | | | | implmentations of rebind_alloc based on whether or not we had template aliases. Create a helper struct to encapsulate that bit of logic, and replace all the ifdefs with uses of that struct. No functionality change intented. llvm-svn: 234296
* [libc++] Fix PR22922 - Allocator support for std::function does not know how ↵Eric Fiselier2015-03-181-2/+16
| | | | | | | | | | | | | | | | | | | to rebind. Summary: This patch changes std::function to use allocator_traits to rebind the allocator instead of allocator itself. It also changes most of the tests to use `bare_allocator` where possible instead of `test_allocator`. Reviewers: mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8391 llvm-svn: 232686
* Add trailing return types (and noexcept specifications) to the 'diamond ↵Marshall Clow2015-02-251-18/+54
| | | | | | operators'. Fixes PR#22600. llvm-svn: 230484
* [libcxx] Fix PR 22468 - std::function<void()> does not accept ↵Eric Fiselier2015-02-101-2/+3
| | | | | | | | | | | | | | | | | | | 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
* Prevent ill-formed instantiation of __invoke_of<...> during the evaluation ↵Eric Fiselier2014-12-231-2/+2
| | | | | | | | | | | | | | | | of a bind expression. Fixes PR22003. The SFINAE on the function __mu(Fn, Args...) that evaluates nested bind expressions always tries to deduce the return type for Fn(Args...) even when Fn is not a nested bind expression. This can cause hard compile errors when the instantation of Fn(Args...) is ill-formed. This patch prevents the instantation of __invoke_of<Fn, Args...> unless Fn is actually a bind expression. Bug reportand patch from Michel Morin. http://llvm.org/bugs/show_bug.cgi?id=22003 llvm-svn: 224753
* Fix libc++ bug #20039: 'Constructing std::function from empty compatible ↵Marshall Clow2014-06-301-1/+1
| | | | | | std::function results in half-empty state' Thanks to Agustin Berge for the report, and for his and Eric Fiselier's work on a fix. llvm-svn: 212070
* Some calls to get<>() were qualified. Some were not. Qualify them all. Fixes ↵Marshall Clow2014-06-241-3/+3
| | | | | | bug #20092. Thanks to Agustín Bergé for the bug report and the fix. llvm-svn: 211563
* Bug #19473. If you pass an allocator to std::function, we should use that ↵Marshall Clow2014-04-181-10/+11
| | | | | | allocator, not construct one from scratch. Add a test to make sure llvm-svn: 206623
* Const qualify __mem_fn call operatorPeter Collingbourne2014-01-221-1/+1
| | | | | | | | QOI improvement. Differential Revision: http://llvm-reviews.chandlerc.com/D2059 llvm-svn: 199848
* Implement n3789; constexpr support in named function objectsMarshall Clow2013-09-281-43/+83
| | | | llvm-svn: 191626
* Apply LWG 2048. It is amazing to me that this actually works, but the ↵Howard Hinnant2013-09-211-44/+0
| | | | | | existing tests confirm that it does. c++1y status page now showing libc++ is complete for c++1y modulo dynarray issues. llvm-svn: 191142
* Apply LWG 2017. This is a only a documentation change.Howard Hinnant2013-09-211-1/+1
| | | | llvm-svn: 191140
* LWG Issue 2148: Hashing EnumsMarshall Clow2013-09-031-0/+16
| | | | llvm-svn: 189831
* First half of support for N3657; heterogenous lookups for set/multisetMarshall Clow2013-08-131-0/+18
| | | | llvm-svn: 188241
* Nico Rieck: this patch series fixes visibility issues on Windows as ↵Howard Hinnant2013-08-121-82/+82
| | | | | | explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>. llvm-svn: 188192
* Implement N3421; comparison predicates<void>Marshall Clow2013-07-291-15/+311
| | | | llvm-svn: 187357
* The bind and function functor constructors and assignment operators were ↵Howard Hinnant2013-07-011-7/+24
| | | | | | overly general and getting confused with the copy constructor and copy assignment operators. Constrained them. This fixes http://llvm.org/bugs/show_bug.cgi?id=16385 llvm-svn: 185297
* Fix bind by making _is_valid_bind_return more robust. It should return ↵Howard Hinnant2013-06-301-1/+13
| | | | | | false instead of give a compile time error, always. The problem was down in ____mu_return, the version that handles nested bind objects. This fixes http://llvm.org/bugs/show_bug.cgi?id=16343 llvm-svn: 185289
* No functionality change at this time. I've split _LIBCPP_VISIBLE up into ↵Howard Hinnant2013-03-061-53/+53
| | | | | | 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
* Constrain bind operator()() to not exist if the call is not valid. Fixes ↵Howard Hinnant2013-02-211-6/+42
| | | | | | http://llvm.org/bugs/show_bug.cgi?id=15295. llvm-svn: 175774
* Revert accidental check-in. These changes are probably good, but premature ↵Howard Hinnant2013-02-071-24/+0
| | | | | | at this point. llvm-svn: 174625
* Michael van der Westhuizen: The attached patch add support for building ↵Howard Hinnant2013-02-071-0/+24
| | | | | | | | | | | against libc++abi and libcxxrt to CMake builds of libc++. Usage (with the appropriate CC and CXX environment variables) is: $ cmake -DLIBCXX_CXX_ABI=libcxxabi '-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=/home/michael/libcxxabi/include' ../libcxx and: $ cmake -DLIBCXX_CXX_ABI=libcxxrt '-DLIBCXX_LIBCXXRT_INCLUDE_PATHS=/home/michael/libcxxrt/src' ../libcxx llvm-svn: 174623
* Donated anonymously: This enables GCC 4.8.0 to build libc++.Howard Hinnant2013-01-211-1/+1
| | | | llvm-svn: 173060
* Don't neglect to "return *this".Argyrios Kyrtzidis2012-10-131-0/+2
| | | | llvm-svn: 165860
* Further tweaks on relaxing complete type checking for function.Howard Hinnant2012-07-201-1/+2
| | | | llvm-svn: 160562
* Constrain __bind functor constructor such that it won't accidentally get ↵Howard Hinnant2012-05-041-1/+5
| | | | | | used as a copy constructor from a non-const lvalue. Fixes <rdar://problem/11359080>. llvm-svn: 156182
* Reduce the number of move constructions when constructing a std::function. ↵Howard Hinnant2012-02-281-2/+16
| | | | | | This fixes http://llvm.org/bugs/show_bug.cgi?id=12105. llvm-svn: 151652
* Modernize conversion to bool to the explicit bool conversion operator ↵Howard Hinnant2012-02-211-1/+1
| | | | | | (library wide). This fixes http://llvm.org/bugs/show_bug.cgi?id=12058. llvm-svn: 151088
* Modernize relational operators for shared_ptr and unique_ptr. This includes ↵Howard Hinnant2012-02-211-6/+1
| | | | | | adding support for nullptr, and using less<T*>. Fixes http://llvm.org/bugs/show_bug.cgi?id=12056. llvm-svn: 151084
* Version #next on the hash functions for scalars. This builds on Dave's ↵Howard Hinnant2011-12-031-77/+45
| | | | | | work, extends it to T*, and changes the way double and long double are handled (no longer convert to float on 32 bit). I also picked up a minor bug with uninitialized bits on the upper end of size_t when sizeof(size_t) > sizeof(T), e.g. in hash<float>. Most of the functionality has been put in one place: __scalar_hash in <memory>. Unfortunately I could not reuse __scalar_hash for hash<long double> on x86 because of the padding bits which need to be zeroed. I didn't want to add this zeroing step to the more general __scalar_hash when it isn't needed (in the absence of padding bits). I'm not ignoring the hash<string> issue (possibly changing that to a better hash). I just haven't gotten there yet. llvm-svn: 145778
* I had picked up the wrong version of DaveZ's hash patches. Corrected here.Howard Hinnant2011-12-021-39/+49
| | | | llvm-svn: 145728
* Fixes to hash for long long, unsigned long long, float, double and long ↵Howard Hinnant2011-12-021-22/+56
| | | | | | double. Credit Dave Zarzycki llvm-svn: 145721
* Quash a whole bunch of warningsHoward Hinnant2011-12-011-1/+1
| | | | llvm-svn: 145624
* Further macro protection by replacing _[A-Z] with _[A-Z]pHoward Hinnant2011-11-291-225/+225
| | | | llvm-svn: 145410
* Windows support by Ruben Van Boxem.Howard Hinnant2011-10-171-0/+2
| | | | llvm-svn: 142235
* http://llvm.org/bugs/show_bug.cgi?id=10250Howard Hinnant2011-07-021-0/+47
| | | | llvm-svn: 134325
OpenPOWER on IntegriCloud