Commit Graph

74 Commits

Author SHA1 Message Date
Eric Fiselier 4268a742f5 Fix pair::operator=(TupleLike&&).
This assignment operator was previously broken since the SFINAE always resulted
in substitution failure. This caused assignments to turn into
copy construction + assignment.

This patch was originally committed as r279953 but was reverted due to warnings
in the test-suite. This new patch corrects those warnings.

llvm-svn: 279955
2016-08-29 01:43:41 +00:00
Eric Fiselier 67c2344174 Revert r279953 - Fix pair::operator=(TupleLike&&)
The test emits warnings causing the test-suite to fail. Since I want this
patch merged into 3.9 I'll recommit it with a clean test.

llvm-svn: 279954
2016-08-29 01:39:54 +00:00
Eric Fiselier 0678cc793a Fix pair::operator=(TupleLike&&).
This assignment operator was previously broken since the SFINAE always resulted
in substitution failure. This caused assignments to turn into
copy construction + assignment.

llvm-svn: 279953
2016-08-29 01:09:47 +00:00
Eric Fiselier 4927c29577 Implement the std::pair parts of "Improving pair and tuple". Completes N4387.
llvm-svn: 276605
2016-07-25 04:32:07 +00:00
Eric Fiselier aedcbf898b Recommit r276548 - Make pair/tuples assignment operators SFINAE properly.
I think I've solved issues with is_assignable and references to incomplete
types. The updated patch adds tests for this case.

llvm-svn: 276603
2016-07-25 02:36:42 +00:00
Eric Fiselier 189f88ca35 Revert r276548 - Make pair/tuples assignment operators SFINAE properly.
This is a breaking change. The SFINAE required is instantiated the second
the class is instantiated, and this can cause hard SFINAE errors
when applied to references to incomplete types. Ex.

struct IncompleteType;
extern IncompleteType it;
std::tuple<IncompleteType&> t(it); // SFINAE will blow up.

llvm-svn: 276598
2016-07-25 01:45:07 +00:00
Eric Fiselier 4e91ea50a0 Don't SFINAE pair's copy assignment operator in C++03 mode.
In C++03 mode evaluating the SFINAE can cause a hard error due to
access control violations. This is a problem because the SFINAE
is evaluated as soon as the class is instantiated, and not later.

llvm-svn: 276594
2016-07-25 00:48:36 +00:00
Eric Fiselier 8f5abc12bb Add __is_inplace_type metafunction helper
llvm-svn: 276556
2016-07-24 07:42:13 +00:00
Eric Fiselier 904a5d7007 Make pair/tuples assignment operators SFINAE properly.
llvm-svn: 276548
2016-07-24 05:51:11 +00:00
Eric Fiselier 58ad17df0f Implement the in_place tags from p0032r3.
That paper also has changes to any/optional but those will
be implemented later.

llvm-svn: 276537
2016-07-23 22:19:19 +00:00
Eric Fiselier 35b6413d1b Rename and rework `_LIBCPP_TRIVIAL_PAIR_COPY_CTOR`. Move FreeBSD configuration in-tree.
This patch does the following:

* It renames `_LIBCPP_TRIVIAL_PAIR_COPY_CTOR` to `_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR`.
* It automatically enables this option on FreeBSD in ABI V1, since that's the current ABI FreeBSD ships.
* It cleans up the handling of this option in `std::pair`.

I would like the sign off from the FreeBSD maintainers. They will no longer need to keep their `__config` changes downstream.

I'm still hoping to come up with a better way to maintain the ABI without needing these constructors.

Reviewed in https://reviews.llvm.org/D21329

llvm-svn: 275749
2016-07-18 01:58:37 +00:00
Eric Fiselier 9743af6e31 Replace __make_tuple_indices implementation with superior implementation.
The previous __make_tuple_indices implementation caused O(N) instantiations
and was pretty inefficient. The C++14 __make_integer_sequence implementation
is much better, since it either uses a builtin to generate the sequence or
a very nice Log8(N) implementation provided by richard smith.

This patch moves the __make_integer_sequence implementation into __tuple
and uses it to implement __make_tuple_indices.

Since libc++ can't expose the name 'integer_sequence' in C++11 this patch
also introduces a dummy type '__integer_sequence' which is used when generating
the sequence. One the sequence is generated '__integer_sequence' can be
converted into the required type; either '__tuple_indices' or 'integer_sequence'.

llvm-svn: 274286
2016-06-30 22:34:43 +00:00
Marshall Clow 92c9fef95f Test commit; remove some spaces at EOL. No functional change.
llvm-svn: 273121
2016-06-19 19:29:52 +00:00
Eric Fiselier 3d30c32f02 Partially Revert r272613. FreeBSD needs the non-trivial constructors in pair.
llvm-svn: 272671
2016-06-14 14:34:19 +00:00
Eric Fiselier fbe79c9d25 Remove _LIBCPP_TRIVIAL_PAIR_COPY_CTOR option.
llvm-svn: 272613
2016-06-14 01:36:15 +00:00
Eric Fiselier f07dd8d0a9 Add is_swappable/is_nothrow_swappable traits
llvm-svn: 267079
2016-04-21 23:38:59 +00:00
Ben Craig 8743f8ca24 Include initializer_list from utility
The C++11 and C++14 standards both say in the header <utility> synopsis that
<utility> shall include <initializer_list>.

llvm-svn: 266808
2016-04-19 20:13:55 +00:00
Eric Fiselier 2152fd7682 Implement LWG issue 2219 - support reference_wrapper in INVOKE
llvm-svn: 266590
2016-04-18 06:17:30 +00:00
Eric Fiselier 7a608aa232 [libcxx] Fix LWG Issue #2367 - Fixing std::tuple and std::pair's default constructors.
Summary: This patch implements the solution for LWG Issue #2367. See http://cplusplus.github.io/LWG/lwg-active.html#2367

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13750

llvm-svn: 256325
2015-12-23 08:20:26 +00:00
Eric Fiselier 545b8861fc [libcxx] LWG2485: get() should be overloaded for const tuple&&. Patch from K-Ballo.
Review: http://reviews.llvm.org/D14839
llvm-svn: 255941
2015-12-18 00:36:55 +00:00
Eric Fiselier af5b54a249 Workaround nasty GCC bug that caused testsuite to hang
llvm-svn: 255734
2015-12-16 00:35:45 +00:00
Eric Fiselier fff5ec035b Use __make_integer_seq builtin for std::make_integer_sequence. Patch by K-ballo.
llvm-svn: 255162
2015-12-09 22:03:06 +00:00
Marshall Clow bfb3f2bf7d Fix some mistakes in the <utility> and <tuple> synopses. No functional change. Thannks to K-ballo for the patch
llvm-svn: 253593
2015-11-19 19:45:29 +00:00
Marshall Clow dbd2d32892 Implement P0007: Constant View: A proposal for a std::as_const helper function template.
llvm-svn: 253274
2015-11-17 00:08:08 +00:00
Marshall Clow 0510a5adc8 Change pair::swap(pair&) to call ADL swap instead of iter_swap; this fixes an obscure bug having to do with overloaded operator&. Fixes PR#24890
llvm-svn: 248304
2015-09-22 17:50:11 +00:00
Eric Fiselier 57f00f2f9c [libcxx] Move tuple_size and tuple_element overloads for pair and array out of !defined(_LIBCPP_HAS_NO_VARIADICS) block.
Summary:
There is no reason to guard `tuple_size`, `tuple_element` and `get<I>(...)` for pair and array inside of `<__tuple>` so that they are only available when we have variadic templates.
This requires there be redundant declarations and definitions. It also makes it easy to get things wrong.

For example the following code should compile (and does in c++11).
```
#define _LIBCPP_HAS_NO_VARIADICS
#include <array>

int main()
{
  static_assert((std::tuple_size<std::array<int, 10> volatile>::value == 10), "");
}
```

This patch lifts the non-variadic parts of `tuple_size`, `tuple_types`, and `get<I>(...)` to the top of `<__tuple>` where they don't require variadic templates. This patch also removes `<__tuple_03>` because there is no longer a need for it.


Reviewers: danalbert, K-ballo, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D7774

llvm-svn: 232492
2015-03-17 15:08:03 +00:00
Marshall Clow f6d58a2a1f Make the forward declaration for array swap have the same inline/visibility attributes as the definition. Thanks to Steven Wu for the catch.
llvm-svn: 230330
2015-02-24 12:46:39 +00:00
Marshall Clow d632356aa3 Fix PR 22106; make std::swap work for multi-dimensional arrays. Thanks to Peter Griess for the report and suggested fix
llvm-svn: 225285
2015-01-06 19:20:49 +00:00
Eric Fiselier 910285b238 [libcxx] Fix use of operator comma where the types can be user defined
Summary:
An evil user might overload operator comma. Use a void cast to make sure any user overload is not selected.
Modify all the test iterators to define operator comma. 

Reviewers: danalbert, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D5929

llvm-svn: 220706
2014-10-27 19:28:20 +00:00
Marshall Clow f9af6140ff Some calls to get<>() were qualified. Some were not. Qualify them all. Fixes bug #20092. Thanks to Agustín Bergé for the bug report and the fix.
llvm-svn: 211563
2014-06-24 00:46:19 +00:00
Marshall Clow 05c8dad230 Implement LWG Paper n3887: Consistent Metafunction Aliases. This adds std::tuple_element_t<> as an alias for tuple_element<>::type. Clean up the synopsis for tuple_element in <utility> as well.
llvm-svn: 202673
2014-03-03 06:18:11 +00:00
Marshall Clow 0724bf6767 Rename ___make_pair_return to __make_pair_return_impl; ___make_tuple_return to __make_tuple_return_impl; and ____iterator_traits to __iterator_traits_impl. Part of a campaign to remove > 2 underscores from libc++. No functionality change.
llvm-svn: 198457
2014-01-03 22:55:49 +00:00
Howard Hinnant f9fd0d6d11 This is a followup to r194536, which changed the pair copy constructor to be
trivial in C++03, thus making it trivial in both C++03 and C++11.

This patch allows one to opt-in/out of this decision with a macro.  You can
choose to have the pair copy constructor always be trivial, or always be
non-trivial.  The flag controlling this is now _LIBCPP_TRIVIAL_PAIR_COPY_CTOR.

The client can define this flag to 1, and the pair copy constructor will be
trivial (when possible of course), or to 0, and the pair copy constructor will
be nontrivial.

Default settings for this flag are set in <__config> (as usual).  With this
commit the default is _LIBCPP_TRIVIAL_PAIR_COPY_CTOR=1 for all platforms
except __APPLE__, which defaults to _LIBCPP_TRIVIAL_PAIR_COPY_CTOR=0.

llvm-svn: 194742
2013-11-14 22:52:25 +00:00
Howard Hinnant ccad8c32e0 This fixes a very subtle ABI problem concerning the copy constructor of
pair, and a couple of pair-like implementation detail types.  The
C++98/03 and 11 standards all specify that the copy constructor of
pair<int, int> is trivial. However as libc++ tracked the draft C++11
standard over the years, this copy constructor became non-trivial, and
then just recently was corrected back to trivial for C++11.

Unfortunately (for libc++1) the Itanium ABI specifies different calling
conventions for trivial and non-trivial copy constructors.  Therefore
currently the C++03 libc++ copy constructor for pair<int, int> is ABI
incompatible with the C++11 libc++ copy constructor for pair<int, int>.
This is Bad(tm).   This patch corrects the situation by making this copy
constructor trivial in C++03 mode as well.

Just in case it is needed for an incomplete C++11 compiler, libc++
retains the ability to support pair with rvalue references, but without
defaulted special members.  However the pair needs non-trivial special
members to implement this special case, (as it did when clang was in
this place a couple of years ago).

During this work a bug was also found and fixed in
is_trivially_constructible.

And there is a minor drive-by fix in <__config> regarding
__type_visibility__.

A test is updated to ensure that the copy constructor of pair<int, int>
is trivial in both C++03 and C++11.  This test will necessarily fail for
a compiler that implements rvalue references but not defaulted special
members.

llvm-svn: 194536
2013-11-13 00:39:22 +00:00
Howard Hinnant 3af48ef76e G M: Changes all references to "x inline" to "inline x" where x = _libcpp_always_inline or _libcpp_inline_visibility macros.
The patch touches these files:

locale
array
deque
new
string
utility
vector
__bit_reference
__split_buffer
locale_win32.h
 
There is no intended functionality change and it is expected that reversing the position of the inline keyword with regard to the other keywords does not change the meaning of anything, least not for apple/Linux etc.
 
It is intended to make libcxx more consistent with itself and to prevent the 1000 or so
"inline.cpp(3) : warning C4141: 'inline' : used more than once" warnings that MS's cl.exe compiler emits without this patch, i.e. if inline is not the first keyword before a function name etc.
 
Prefer "inline [other inline related keyword]" over "[other related keyword] inline".
After this patch, libcxx should be consistent to this pattern.

llvm-svn: 191987
2013-10-04 22:09:00 +00:00
Howard Hinnant f0544c2086 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>.
llvm-svn: 188192
2013-08-12 18:38:34 +00:00
Marshall Clow 8bf1f08a2c Make std::get constexpr
llvm-svn: 186525
2013-07-17 18:25:36 +00:00
Marshall Clow 18191ceb54 Bug 16599 part 2: Make std::pair's constructors and comparison operators (and make_pair) constexpr.
llvm-svn: 186430
2013-07-16 17:45:44 +00:00
Marshall Clow 1c682f0f0c Make std::forward and std::move (and std::move_if_noexcept) constexpr in C++14
llvm-svn: 186344
2013-07-15 20:46:11 +00:00
Marshall Clow e99520c72e Implement n3584 - Addressing Tuples by Type
llvm-svn: 186237
2013-07-13 02:54:05 +00:00
Howard Hinnant e0fe3d2e96 War on tabs.
llvm-svn: 185865
2013-07-08 21:06:38 +00:00
Marshall Clow a7b0e5ddf8 Implement n3668 - std::exchange
llvm-svn: 185863
2013-07-08 20:54:40 +00:00
Marshall Clow 60df5996a4 Commit patch for integer sequences. Suggested by Richard, reworked by Howard, and annotated by me
llvm-svn: 185569
2013-07-03 19:20:30 +00:00
Marshall Clow d51891063f Implement n3658 - Compile-time integer sequences
llvm-svn: 185343
2013-07-01 16:26:55 +00:00
Howard Hinnant 6e41256f68 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.
llvm-svn: 176593
2013-03-06 23:30:19 +00:00
Howard Hinnant a01739a03a Enable the tuple interface of pair in C++03 mode.
llvm-svn: 167491
2012-11-06 21:42:45 +00:00
Howard Hinnant aeb85680fb Dimitry Andric: many visibility fixes. Howard: Much appreciated. Can you send me a patch to CREDITS.TXT?
llvm-svn: 163862
2012-09-14 00:39:16 +00:00
Howard Hinnant c418654096 Revert pair constructors back to using is_convertible instead of is_constructible. This should pull things into alignment with the final draft. Fixes http://llvm.org/bugs/show_bug.cgi?id=13063#add_comment.
llvm-svn: 158280
2012-06-09 20:01:23 +00:00
Howard Hinnant 7e5b4c9328 Put std::piecewise_construct_t back into the dylib for ABI stability. When clients are in C++11/constexpr mode this will be safely ignored because piecewise_construct is then declared with internal linkage.
llvm-svn: 153981
2012-04-03 23:45:46 +00:00
Howard Hinnant b2e9f19caf constexpr support for <utility>. Patch contributed by Jonathan Sauer.
llvm-svn: 153968
2012-04-03 21:09:48 +00:00