Commit Graph

15 Commits

Author SHA1 Message Date
Eric Fiselier dc808af38d Fix LWG 2934 - optional<const T> doesn't compare with T
llvm-svn: 299105
2017-03-30 20:06:52 +00:00
Eric Fiselier d3209f932f Implement LWG 2842 - optional(U&&) needs to SFINAE on decay_t<in_place_t>
llvm-svn: 299100
2017-03-30 19:43:50 +00:00
Marshall Clow 7c803385a7 Implement P0599: 'noexcept for hash functions'. Fix a couple of hash functions (optional<T> and unique_ptr<T>) which were mistakenly marked as 'noexcept'. Reviewed as https://reviews.llvm.org/D31234
llvm-svn: 298573
2017-03-23 02:40:28 +00:00
Marshall Clow 6a1d078560 Restore the _NOEXCEPT on the dtor of bad_optional_access. Destructors are noexcept by default, so it's not really needed, but the other exception classes have the _NOEXCEPT, and gcc complains if these are missing. I think we should remove them all - but not today.
llvm-svn: 294142
2017-02-05 20:52:32 +00:00
Marshall Clow e29b1ed50b Change the base class of std::bad_optional_access. This is a (subtle) ABI change, and is in response to http://http://wg21.link/LWG2806, which I *expect* to be adopted in Kona. I am making this change now in anticipation, and will get it into 4.0, because (a) 4.0 is the first release with std::optional, and (b) I don't want to make an ABI-change later, when the user base should be significantly larger. Note that I didn't change std::experimental::bad_optional_access, because that's still specified to derive from std::logic_error.
llvm-svn: 294133
2017-02-05 20:06:38 +00:00
Eric Fiselier f9127593a9 Implement P0513R0 - "Poisoning the Hash"
Summary:
Exactly what the title says.

This patch also adds a `std::hash<nullptr_t>` specialization in C++17, but it was not added by this paper and I can't find the actual paper that adds it.

See http://wg21.link/P0513R0 for more info.

If there are no comments in the next couple of days I'll commit this

Reviewers: mclow.lists, K-ballo, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

llvm-svn: 292684
2017-01-21 00:02:12 +00:00
Eric Fiselier e2f2d1edef [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS
The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both
_LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to
__attribute__((__type_visibility__)) with Clang. The only remaining difference
is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas
_LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on
templates).

This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS.

llvm-svn: 291035
2017-01-04 23:56:00 +00:00
Saleem Abdulrasool 21711c451e remove some inherited attributes on exceptions
These exception types are marked with `_LIBCPP_EXCEPTION_ABI` which
expands to `__attribute__((__visibility__("default")))` or
`__declspec(dllexport)`.  When building for Windows, we would hit an
error:

    cannot apply 'dllexport' to a 'dllexport' class

Remove the duplicate annotations as they will be inherited from the
class.

llvm-svn: 290785
2016-12-31 17:34:26 +00:00
Eric Fiselier fd83822741 Fix unused parameters and variables
llvm-svn: 290459
2016-12-23 23:37:52 +00:00
Eric Fiselier 015fcffd57 Update status for std::optional LWG issues and fix an optional SFINAE bug
llvm-svn: 284323
2016-10-16 03:21:35 +00:00
Eric Fiselier a9e659619f Implement N4606 optional
Summary:
Adapt implementation of Library Fundamentals TS optional into an implementation of N4606 optional.

  - Update relational operators per http://wg21.link/P0307
  - Update to requirements of http://wg21.link/P0032
  - Extension: Implement trivial copy/move construction/assignment for `optional<T>` when `T` is trivially copyable.

Audit P/Rs for optional LWG issues:
  - 2756 "C++ WP optional<T> should 'forward' T's implicit conversions" Implemented, which also resolves 2753 "Optional's constructors and assignments need constraints" (modulo my refusal to explicitly delete the move operations, which is a design error that I'm working on correcting in the 2756 P/R).
  - 2736 "nullopt_t insufficiently constrained" Already conforming. I've added a test ensuring that `nullopt_t` is not copy-initializable from an empty braced-init-list, which I believe is the root intent of the issue, to avoid regression.
  - 2740 "constexpr optional<T>::operator->" Already conforming.
  - 2746 "Inconsistency between requirements for emplace between optional and variant" No P/R, but note that the author's '"suggested resolution" is already implemented.
  - 2748 "swappable traits for optionals" Already conforming.
  - 2753 "Optional's constructors and assignments need constraints" Implemented.

Most of the work for this patch was done by Casey Carter @ Microsoft. Thank you Casey!



Reviewers: mclow.lists, CaseyCarter, EricWF

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

llvm-svn: 283980
2016-10-12 07:46:20 +00:00
Eric Fiselier fc647db3ee Revert Add <optional>. Will recommit with better commit message
llvm-svn: 283978
2016-10-12 06:48:31 +00:00
Eric Fiselier 6ee4001cc9 Add <optional> header.
This patch is largely thanks to Casey Carter @ Microsoft. He did the initial
work of porting our experimental implementation and tests over to namespace
std.

llvm-svn: 283977
2016-10-12 06:45:11 +00:00
Marshall Clow dfdac03c8f Move <optional> into include/experimental, and into the std::experimental namespace, since it's not part of C++14, but of an upcoming TS
llvm-svn: 194867
2013-11-15 22:42:10 +00:00
Howard Hinnant e7d746d8b9 Implement N3672, optional<T>.
llvm-svn: 189772
2013-09-02 20:30:37 +00:00