Commit Graph

49 Commits

Author SHA1 Message Date
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
Howard Hinnant a87b5e3446 Fix http://llvm.org/bugs/show_bug.cgi?id=11616
llvm-svn: 146881
2011-12-19 17:58:44 +00:00
Howard Hinnant c003db1fca Further macro protection by replacing _[A-Z] with _[A-Z]p
llvm-svn: 145410
2011-11-29 18:15:50 +00:00
Howard Hinnant 073458b1ab Windows support by Ruben Van Boxem.
llvm-svn: 142235
2011-10-17 20:05:10 +00:00
Howard Hinnant 02364191d6 Fix PR10509: http://llvm.org/bugs/show_bug.cgi?id=10509
llvm-svn: 136247
2011-07-27 19:25:28 +00:00
Howard Hinnant b929de3c3d Changed constraints on pair and tuple constructors from is_convertible to is_constructible.
llvm-svn: 134252
2011-07-01 20:12:51 +00:00
Howard Hinnant 5a33687da0 Correct for new rules regarding implicitly deleted special members. http://llvm.org/bugs/show_bug.cgi?id=10191
llvm-svn: 134248
2011-07-01 19:24:36 +00:00
Howard Hinnant ce48a1137d _STD -> _VSTD to avoid macro clash on windows
llvm-svn: 134190
2011-06-30 21:18:19 +00:00
Howard Hinnant bc95cf0d5f Experimental support for a meaningful __is_swappable<T>::value. This does not appear to be strictly needed for correct functioning of the library. If it causes any problems, I'd rather pull it sooner rather than later.
llvm-svn: 132421
2011-06-01 19:59:32 +00:00
Howard Hinnant 27d0a2a75d noexcept for <tuple>. And in the process learned that I had done it wrong for pair's swap. I needed to create an __is_nothrow_swappable<T>::value trait that was smart enought to answer false when __is_swappable<T>::value is false. Otherwise one gets compile-time errors when using pair or tuple of non-swappable types, even if you never try to swap the pair or tuple.
llvm-svn: 132204
2011-05-27 19:08:18 +00:00
Howard Hinnant a676f7d36a noexcept for <utility>. This included a little repair on pair, and some noexcept workarounds.
llvm-svn: 132186
2011-05-27 15:04:19 +00:00
Howard Hinnant 575d41ee92 Correction to set of overloaded pair constructors for C++0x
llvm-svn: 130521
2011-04-29 18:10:55 +00:00
Howard Hinnant 2503626838 Add attribute to inlined member.
llvm-svn: 123392
2011-01-13 20:05:05 +00:00
Michael J. Spencer f5799be4a8 Add CMake build and fix major Linux blockers.
llvm-svn: 121510
2010-12-10 19:47:54 +00:00
Howard Hinnant ca74048398 N3142. Many of these traits are just placeholders with medium quality emulation; waiting on compiler intrinsics to do it right.
llvm-svn: 119854
2010-11-19 22:17:28 +00:00
Howard Hinnant 601afb30ec LWG 1191
llvm-svn: 119545
2010-11-17 19:52:17 +00:00
Howard Hinnant 412dbebe1b license change
llvm-svn: 119395
2010-11-16 22:09:02 +00:00
Howard Hinnant c4931c4746 I have reverted all contributions made by Jesse Towner in revision 110724
llvm-svn: 119383
2010-11-16 21:10:23 +00:00
Howard Hinnant 789847ddbb visibility-decoration sweep completed.
llvm-svn: 114685
2010-09-23 18:58:28 +00:00
Howard Hinnant 7609c9b665 Changed __config to react to all of clang's currently documented has_feature flags, and renamed _LIBCPP_MOVE to _LIBCPP_HAS_NO_RVALUE_REFERENCES to be more consistent with the rest of the libc++'s flags, and with clang's nomenclature.
llvm-svn: 113086
2010-09-04 23:28:19 +00:00
Howard Hinnant b3371f6f49 Fixing whitespace problems
llvm-svn: 111750
2010-08-22 00:02:43 +00:00
Howard Hinnant 907af2668f GB 85, GB 87
llvm-svn: 111546
2010-08-19 19:15:54 +00:00
Howard Hinnant eb2692571f patch by Jesse Towner, and bug fix by Sebastian Redl
llvm-svn: 110724
2010-08-10 20:48:29 +00:00
Howard Hinnant 5b08a8a432 Wiped out some non-ascii characters that snuck into the copyright.
llvm-svn: 103516
2010-05-11 21:36:01 +00:00
Howard Hinnant 3e519524c1 libcxx initial import
llvm-svn: 103490
2010-05-11 19:42:16 +00:00