summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/function.objects
Commit message (Collapse)AuthorAgeFilesLines
...
* Add missing license headersEric Fiselier2016-01-192-0/+18
| | | | llvm-svn: 258196
* One more missing std:: qualification from JonathanMarshall Clow2016-01-121-1/+2
| | | | llvm-svn: 257506
* Add tests for the extended integer types - as required by LWG#2119Marshall Clow2015-11-171-0/+40
| | | | llvm-svn: 253376
* Fix typo I just introduced.Marshall Clow2015-11-101-1/+1
| | | | llvm-svn: 252614
* Explicitly #include <utility> so that we get std::move. Thanks to Walter for ↵Marshall Clow2015-11-101-0/+1
| | | | | | the bug report. llvm-svn: 252610
* Fix LWG#2489: mem_fn() should be noexceptMarshall Clow2015-10-251-0/+3
| | | | llvm-svn: 251257
* [libcxx] Rewrite C++03 __invoke.Eric Fiselier2015-08-262-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+247
| | | | | | | | | | | | | | | | | | | | 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
* Checking more __invoke tests.Eric Fiselier2015-07-284-0/+1126
| | | | | | | Before I start trying to fix __invoke in C++03 it needs better test coverage. This patch adds a large amount of tests for __invoke. llvm-svn: 243366
* Cleanup <__functional_03>Eric Fiselier2015-07-229-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | <__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
* Cleanup tests that fail in C++1z and with Clang 3.8Eric Fiselier2015-07-177-369/+242
| | | | llvm-svn: 242581
* Remove non-ascii charactersEric Fiselier2015-07-141-5/+5
| | | | llvm-svn: 242197
* Implement n4169 - Add invoke function templateEric Fiselier2015-07-141-0/+268
| | | | llvm-svn: 242195
* [libcxx] LWG2420 bits for bind<void> - Patch from K-BalloEric Fiselier2015-07-101-3/+16
| | | | | | | Implemented LWG2420 bits for bind<void> Review: http://reviews.llvm.org/D10997 llvm-svn: 241967
* Fix std::function allocator constructors in C++03.Eric Fiselier2015-06-143-119/+206
| | | | | | | | | The C++03 version of function tried to default construct the allocator in the uses allocator constructors when no allocation was performed. These constructors would fail to compile when used with allocators that had no default constructor. llvm-svn: 239708
* [libc++] Fix PR22922 - Allocator support for std::function does not know how ↵Eric Fiselier2015-03-185-15/+18
| | | | | | | | | | | | | | | | | | | 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
* [libcxx] Fix PR 22468 - std::function<void()> does not accept ↵Eric Fiselier2015-02-104-0/+81
| | | | | | | | | | | | | | | | | | | 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 use of C++11 extensions in C++03 code.Eric Fiselier2015-02-102-1/+3
| | | | llvm-svn: 228698
* Get tests running with warnings. Fix warnings in headers and testsEric Fiselier2015-02-053-1/+13
| | | | llvm-svn: 228344
* Cleaning up the test suite; remove some includes of non-standard file <__config>Marshall Clow2015-01-181-3/+1
| | | | llvm-svn: 226411
* In early C++11 standard drafts, std::function derived from ↵Marshall Clow2015-01-081-29/+88
| | | | | | std::unary_function or std::binary_function if there was only one (or two) parameters. Before C++11 shipped, this restiction was lifted, but libc++ still does this (which is fine). However, the tests still check for this outdated requiremnt. Change then to check for the nested typedefs instead (which are still required by the standard). No change to the library. llvm-svn: 225430
* Missed a typenameMarshall Clow2015-01-071-2/+2
| | | | llvm-svn: 225408
* libc++ implements its' hash objects as deriving from std::unary_function, ↵Marshall Clow2015-01-074-12/+19
| | | | | | and the tests test for that. STL @ MS pointed out that the standard doesn't requie these objects to derive from unary_function, and so the tests should not require that either. Change the tests to check for the embedded typedefs - which ARE required. No change to the library. llvm-svn: 225403
* In C++03, a bunch of the arithmetic/logical/comparison functors (such as ↵Marshall Clow2015-01-074-4/+8
| | | | | | negate/bit_not.pass/logical_not) were defined as deriving from unary_funtion. That restriction was removed in C++11, but the tests still check for this. Change the test to look for the embedded types first_argument/second_argument/result_type. No change to the library, just more standards-compliant tests. Thanks to STL @ Microsoft for the suggestion. llvm-svn: 225402
* Missed one comparison test in r225375Marshall Clow2015-01-071-1/+3
| | | | llvm-svn: 225376
* In C++03, a bunch of the arithmetic/logical/comparison functors (such as ↵Marshall Clow2015-01-0716-16/+48
| | | | | | add/equal_to/logical_or) were defined as deriving from binary_funtion. That restriction was removed in C++11, but the tests still check for this. Change the test to look for the embedded types first_argument/second_argument/result_type. No change to the library, just more standards-compliant tests. Thanks to STL @ Microsoft for the suggestion. llvm-svn: 225375
* Prevent ill-formed instantiation of __invoke_of<...> during the evaluation ↵Eric Fiselier2014-12-231-0/+49
| | | | | | | | | | | | | | | | 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
* [libcxx] Consolidate new/delete replacement in tests and disable it when ↵Eric Fiselier2014-12-229-235/+95
| | | | | | | | | | | | | | | | | | | | using sanitizers. Summary: MSAN and ASAN also replace new/delete which leads to a link error in these tests. Currently they are unsupported but I think it would be useful if these tests could run with sanitizers. This patch creates a support header that consolidates the new/delete replacement functionality and checking. When we are using sanitizers new and delete are no longer replaced and the checks always return true. Reviewers: mclow.lists, danalbert, jroelofs, EricWF Reviewed By: EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6562 llvm-svn: 224741
* Move test into test/std subdirectory.Eric Fiselier2014-12-20102-0/+6174
llvm-svn: 224658
OpenPOWER on IntegriCloud