diff --git a/platform/SingletonPtr.h b/platform/SingletonPtr.h index 790287d..2b873a2 100644 --- a/platform/SingletonPtr.h +++ b/platform/SingletonPtr.h @@ -196,8 +196,8 @@ } mutable T *_ptr; -#if __cplusplus >= 201103L && !defined __CC_ARM - // Align data appropriately (ARM Compiler 5 does not support alignas in C++11 mode) +#if __cplusplus >= 201103L + // Align data appropriately alignas(T) mutable char _data[sizeof(T)]; #else // Force data to be 8 byte aligned diff --git a/platform/cxxsupport/TOOLCHAIN_ARMC5/_move.h b/platform/cxxsupport/TOOLCHAIN_ARMC5/_move.h deleted file mode 100644 index f19d15b..0000000 --- a/platform/cxxsupport/TOOLCHAIN_ARMC5/_move.h +++ /dev/null @@ -1,68 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __move_h -#define __move_h - -namespace std -{ -template -struct remove_reference { using type = T; }; - -template -struct remove_reference { using type = T; }; - -template -struct remove_reference { using type = T; }; - -template -using remove_reference_t = typename remove_reference::type; - -// Note that these implementations do not function as -// constant expressions in ARM C 5, so are not marked constexpr. -// This makes them C++11 compliant, but not C++14. - -// [forward] -template -_TypeT &&forward(remove_reference_t<_TypeT> &__t) noexcept -{ - return static_cast<_TypeT &&>(__t); -} - -template -_TypeT &&forward(remove_reference_t<_TypeT> &&__t) noexcept -{ - return static_cast<_TypeT &&>(__t); -} - -template -remove_reference_t<_TypeT> &&move(_TypeT &&__t) noexcept -{ - return static_cast &&>(__t); -} - -// [utility.exchange] -template -_TypeT exchange(_TypeT &__obj, _TypeU &&__new_val) -{ - _TypeT __old_val = std::move(__obj); - __obj = std::forward<_TypeU>(__new_val); - return __old_val; -} - -} // namespace std - -#endif /* __move_h */ diff --git a/platform/cxxsupport/TOOLCHAIN_ARMC5/array b/platform/cxxsupport/TOOLCHAIN_ARMC5/array deleted file mode 100644 index 54c86c6..0000000 --- a/platform/cxxsupport/TOOLCHAIN_ARMC5/array +++ /dev/null @@ -1,251 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __array -#define __array - -#include // required by standard - -#include <_move.h> -#include // size_t, ptrdiff_t -#include // fill and swap_ranges -#include // integral_constant - -namespace std { -template -struct reverse_iterator; - -// [array] -template -struct array { - // [array.overview] - _TypeT _C_elem[_Size != 0 ? _Size : 1]; - - using value_type = _TypeT; - using size_type = size_t; - using difference_type = ptrdiff_t; - using reference = _TypeT &; - using const_reference = const _TypeT &; - using pointer = _TypeT *; - using const_pointer = const _TypeT *; - using iterator = _TypeT *; - using const_iterator = const _TypeT *; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - // [array.size] - // ARMC5 complains "a constexpr member function is only permitted in a literal class type" - /*constexpr*/ size_type size() const noexcept - { - return _Size; - } - // [array.data] - _TypeT *data() noexcept - { - return _C_elem; - } - const _TypeT *data() const noexcept - { - return _C_elem; - } - // [array.fill] - void fill(const _TypeT &value) - { - std::fill(begin(), end(), value); - } - // [array.swap] - void swap(array &__y) - { - std::swap_ranges(begin(), end(), __y.begin()); - } - _TypeT &at(size_t pos) - { - MBED_ASSERT(pos < size()); - return _C_elem[pos]; - } - const _TypeT &at(size_t pos) const - { - MBED_ASSERT(pos < size()); - return _C_elem[pos]; - } - _TypeT &operator[](size_t pos) - { - return _C_elem[pos]; - } - const _TypeT &operator[](size_t pos) const - { - return _C_elem[pos]; - } - _TypeT &front() - { - return _C_elem[0]; - } - const _TypeT &front() const - { - return _C_elem[0]; - } - _TypeT &back() - { - return _C_elem[_Size - 1]; - } - const _TypeT &back() const - { - return _C_elem[_Size - 1]; - } - /*constexpr*/ bool empty() const noexcept - { - return false; - } - /*constexpr*/ size_type max_size() const noexcept - { - return _Size; - } - iterator begin() noexcept - { - return _C_elem; - } - const_iterator begin() const noexcept - { - return _C_elem; - } - const_iterator cbegin() const noexcept - { - return _C_elem; - } - iterator end() noexcept - { - return _C_elem + _Size; - } - const_iterator end() const noexcept - { - return _C_elem + _Size; - } - const_iterator cend() const noexcept - { - return _C_elem + _Size; - } - reverse_iterator rbegin() noexcept - { - return reverse_iterator(end()); - } - const_reverse_iterator rbegin() const noexcept - { - return const_reverse_iterator(end()); - } - const_reverse_iterator crbegin() const noexcept - { - return const_reverse_iterator(end()); - } - reverse_iterator rend() noexcept - { - return reverse_iterator(begin()); - } - const_reverse_iterator rend() const noexcept - { - return const_reverse_iterator(begin()); - } - const_reverse_iterator crend() const noexcept - { - return const_reverse_iterator(begin()); - } -}; - -template -bool operator==(const array<_TypeT, _Size> &__x, const array<_TypeT, _Size> &__y) -{ - return equal(__x.begin(), __x.end(), __y.begin()); -} - -template -bool operator!=(const array<_TypeT, _Size> &__x, const array<_TypeT, _Size> &__y) -{ - return !(__x == __y); -} - -template -bool operator<(const array<_TypeT, _Size> &__x, const array<_TypeT, _Size> &__y) -{ - return lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); -} - -template -bool operator>(const array<_TypeT, _Size> &__x, const array<_TypeT, _Size> &__y) -{ - return __y < __x; -} - -template -bool operator<=(const array<_TypeT, _Size> &__x, const array<_TypeT, _Size> &__y) -{ - return !(__x > __y); -} - -template -bool operator>=(const array<_TypeT, _Size> &__x, const array<_TypeT, _Size> &__y) -{ - return !(__x < __y); -} - -// [array.special] -template -void swap(array<_TypeT, _Size> &__x, array<_TypeT, _Size> &__y) -{ - __x.swap(__y); -} - -// [array.tuple] -template -struct tuple_size; - -template -struct tuple_size> : integral_constant { }; - -template -struct tuple_element; - -template -struct tuple_element<_Idx, array<_TypeT, _Size>> : type_identity<_TypeT> { - static_assert(_Idx < _Size, "array index out of bounds"); -}; - -template -constexpr _TypeT &get(array<_TypeT, _Size> &__a) noexcept -{ - static_assert(_Idx < _Size, "array index out of bounds"); - return __a._C_elem[_Idx]; -} - -template -_TypeT &&get(array<_TypeT, _Size> &&__a) noexcept -{ - return std::move(get<_Idx>(__a)); -} - -template -constexpr const _TypeT &get(const array<_TypeT, _Size> &__a) noexcept -{ - static_assert(_Idx < _Size, "array index out of bounds"); - return __a._C_elem[_Idx]; -} - -template -const _TypeT &&get(const array<_TypeT, _Size> &&__a) noexcept -{ - return std::move(get<_Idx>(__a)); -} - -} // namespace std - -#endif /* __array */ diff --git a/platform/cxxsupport/TOOLCHAIN_ARMC5/atomic b/platform/cxxsupport/TOOLCHAIN_ARMC5/atomic deleted file mode 100644 index dbbe759..0000000 --- a/platform/cxxsupport/TOOLCHAIN_ARMC5/atomic +++ /dev/null @@ -1,62 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __atomic -#define __atomic - -// Just go straight to the main file -#include - -#define ATOMIC_VAR_INIT(x) { x } -#define ATOMIC_FLAG_INIT MSTD_ATOMIC_FLAG_INIT - -// And then pull it all into our std -namespace std { -using mstd::atomic; -using mstd::atomic_is_lock_free; -using mstd::atomic_store; -using mstd::atomic_store_explicit; -using mstd::atomic_load; -using mstd::atomic_load_explicit; -using mstd::atomic_exchange; -using mstd::atomic_exchange_explicit; -using mstd::atomic_compare_exchange_weak; -using mstd::atomic_compare_exchange_weak_explicit; -using mstd::atomic_compare_exchange_strong; -using mstd::atomic_compare_exchange_strong_explicit; -using mstd::atomic_fetch_add; -using mstd::atomic_fetch_add_explicit; -using mstd::atomic_fetch_sub; -using mstd::atomic_fetch_sub_explicit; -using mstd::atomic_fetch_and; -using mstd::atomic_fetch_and_explicit; -using mstd::atomic_fetch_or; -using mstd::atomic_fetch_or_explicit; -using mstd::atomic_fetch_xor; -using mstd::atomic_fetch_xor_explicit; -using mstd::atomic_flag; -using mstd::atomic_flag_test_and_set; -using mstd::atomic_flag_test_and_set_explicit; -using mstd::atomic_flag_clear; -using mstd::atomic_flag_clear_explicit; -using mstd::atomic_init; -using mstd::memory_order; -using mstd::kill_dependency; -using mstd::atomic_thread_fence; -using mstd::atomic_signal_fence; -} - -#endif /* __atomic */ diff --git a/platform/cxxsupport/TOOLCHAIN_ARMC5/cinttypes b/platform/cxxsupport/TOOLCHAIN_ARMC5/cinttypes deleted file mode 100644 index a24dad5..0000000 --- a/platform/cxxsupport/TOOLCHAIN_ARMC5/cinttypes +++ /dev/null @@ -1,38 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __cinttypes -#define __cinttypes - -#include - -/* Poor but conforming implementation - get everything into global namespace, then add to std */ -#include "stdint.h" -#include "inttypes.h" - -namespace std { - using ::imaxdiv_t; - using ::abs; - using ::div; - using ::imaxabs; - using ::imaxdiv; - using ::strtoimax; - using ::strtoumax; - using ::wcstoimax; - using ::wcstoumax; -} - -#endif /* __cinttypes */ diff --git a/platform/cxxsupport/TOOLCHAIN_ARMC5/initializer_list b/platform/cxxsupport/TOOLCHAIN_ARMC5/initializer_list deleted file mode 100644 index bd8bed4..0000000 --- a/platform/cxxsupport/TOOLCHAIN_ARMC5/initializer_list +++ /dev/null @@ -1,76 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __initializer_list -#define __initializer_list - -#include - -namespace std { - -// [support.initlist] -template -struct initializer_list { - using value_type = _TypeE; - using reference = const _TypeE &; - using const_reference = const _TypeE &; - using size_type = size_t; - using iterator = const _TypeE *; - using const_iterator = const _TypeE *; - - // [support.initlist.cons] - constexpr initializer_list() noexcept : _C_ptr(nullptr), _C_count(0) - { - } - constexpr initializer_list(const _TypeE *p, size_type n) noexcept : _C_ptr(p), _C_count(n) - { - } - // [support.initlist.access] - constexpr const _TypeE *begin() const noexcept - { - return _C_ptr; - } - constexpr const _TypeE *end() const noexcept - { - return _C_ptr + _C_count; - } - constexpr size_t size() const noexcept - { - return _C_count; - } -private: - const _TypeE *_C_ptr; - size_t _C_count; -}; - -// [support.initlist.range] -template -constexpr const _TypeE *begin(initializer_list<_TypeE> il) noexcept -{ - return il.begin(); -} - -template -constexpr const _TypeE *end(initializer_list<_TypeE> il) noexcept -{ - return il.end(); -} - - -} // namespace std - -#endif /* __initializer_list */ - diff --git a/platform/cxxsupport/TOOLCHAIN_ARMC5/mutex b/platform/cxxsupport/TOOLCHAIN_ARMC5/mutex deleted file mode 100644 index a727445..0000000 --- a/platform/cxxsupport/TOOLCHAIN_ARMC5/mutex +++ /dev/null @@ -1,45 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __mutex -#define __mutex - -// Just go straight to the main file - we also need IAR implementation, so do it there -#include - -// And then pull it all into our std -namespace std { -using mstd::defer_lock; -using mstd::defer_lock_t; -using mstd::try_to_lock; -using mstd::try_to_lock_t; -using mstd::adopt_lock; -using mstd::adopt_lock_t; - -using mstd::lock_guard; -using mstd::unique_lock; -using mstd::scoped_lock; -using mstd::try_lock; -using mstd::lock; - -using mstd::once_flag; -using mstd::call_once; - -using mstd::mutex; -using mstd::recursive_mutex; -} - -#endif /* __mutex */ diff --git a/platform/cxxsupport/TOOLCHAIN_ARMC5/tuple b/platform/cxxsupport/TOOLCHAIN_ARMC5/tuple deleted file mode 100644 index 5d3bca5..0000000 --- a/platform/cxxsupport/TOOLCHAIN_ARMC5/tuple +++ /dev/null @@ -1,734 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2019 ARM Limited - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* class tuple implementation based on Sashsa Goldstein's series - * "Implementing std::tuple from The Ground Up". - * - * http://blogs.microsoft.co.il/sasha/2015/01/12/implementing-tuple-part-1/ - * - * tuple_cat based on Peter Dimov's article "Simple C++11 metaprogramming", - * which in turn is based on work by Eric Niebler and Stephan T. Lavavej. - * - * https://www.boost.org/doc/libs/develop/libs/mp11/doc/html/simple_cxx11_metaprogramming.html - * - * As ARM C 5 can't do constexpr std::move or std::forward, there's no way - * tuple can be constexpr either, so this is a C++11 implementation, not C++14. - * - * Allocators are not supported. - */ -#ifndef __tuple -#define __tuple - -#include -#include - -namespace std -{ - -template -struct tuple; - -template -struct tuple_element; - -// ARM C 5 (incorrectly? doesn't allow duplicate using - utility has already done this (for pair) -//template -//using tuple_element_t = typename tuple_element::type; - -template -struct tuple_element> : tuple_element> { }; - -template -struct tuple_element<0, tuple> : type_identity { }; - -template -struct tuple_element : type_identity>> { }; - -template -struct tuple_element : type_identity>> { }; - -template -struct tuple_element : type_identity>> { }; - -template -tuple_element_t> &get(tuple &t) noexcept; - -template -tuple_element_t> &&get(tuple &&t) noexcept; - -template -const tuple_element_t> &get(const tuple &t) noexcept; - -template -const tuple_element_t> &&get(const tuple &&t) noexcept; - -namespace impl { - -/* Tuple element container - tuple has these as multiple base classes */ -template -struct tuple_elem { - constexpr tuple_elem() : value() { } // tuple default constructor value-initializes elements - explicit tuple_elem(const T &val) : value(val) { } - template ::value>> - explicit tuple_elem(U&& val) : value(std::forward(val)) { } - /* Copy and move constructors and assignments implicitly defined (only way to get default move in ARMC5) */ - tuple_elem &operator=(const T &val) { value = val; return *this; } - template ::value>> - tuple_elem &operator=(U&& val) { value = std::forward(val); return *this; } - void swap(T &other) { using namespace std; std::swap(value, other); } - T value; -}; - -template -class tuple_base; - -/* C++17 form - conditional explicit idiom from N4387 */ -template -struct tuple_base, Types...> : tuple_elem... { -private: - template - struct we_are_convertible_from : conjunction...> { }; - - template - struct we_are_constructible_from : conjunction...> { }; - - void ignore(int...) { } -public: - /* Default constructor, 0 args */ - constexpr tuple_base() : tuple_elem()... { } - /* Direct constructor, 1+ args */ - template = 1 && - conjunction...>::value, bool> = false> - explicit tuple_base(const Types &...args) : tuple_elem(args)... { } - /* Converting constructor, 1+ args */ - template = 1 && - conjunction...>::value, bool> = true> - explicit tuple_base(UTypes &&...args) : tuple_elem(std::forward(args))... { } - /* Converting copy constructor */ - template , - is_constructible..., - disjunction, - conjunction &...>>, - negation &>...>>, - negation...>> - > - > - >::value, bool> = true> - explicit tuple_base(const tuple &other) : tuple_elem(get(other))... { } - /* Converting move constructor */ - template , - is_constructible..., - disjunction, - conjunction...>>, - negation>...>>, - negation...>> - > - > - >::value, bool> = true> - explicit tuple_base(tuple &&other) : tuple_elem(std::forward(get(other)))... { } - /* Converting pair copy constructor */ - template , - we_are_constructible_from - >::value, bool> = true> - explicit tuple_base(const pair &pair) : - tuple_base(pair.first, pair.second) { } - /* Converting pair move constructor */ - template , - we_are_constructible_from - >::value, bool> = true> - explicit tuple_base(pair &&pair) : - tuple_elem<0, tuple_element_t<0, tuple>>(std::forward(pair.first)), - tuple_elem<1, tuple_element_t<1, tuple>>(std::forward(pair.second)) { } - - /* Copy and move constructors and assignments implicitly defined (only way to get default move in ARMC5) */ - - template - int do_copy1(const U &other) { - impl::tuple_elem &e = *this; - e = other; - return 0; - } - - template - int do_move1(U &&other) { - impl::tuple_elem &e = *this; - e = std::move(other); - return 0; - } - - template - tuple_base &operator=(const tuple &other) { - ignore(do_copy1(get(other))...); - return *this; - } - - template - void do_move(tuple &&other) { - impl::tuple_elem>> &e = *this; - e = std::forward>>(get(other)); - do_move(std::forward>(other)); - } - - template - tuple_base &operator=(tuple &&other) { - ignore(do_move1(std::forward(get(other)))...); - return *this; - } - - template - tuple_base &operator=(const pair &pair) { - do_copy1<0, tuple_element_t<0, tuple>>(pair.first); - do_copy1<1, tuple_element_t<1, tuple>>(pair.second); - return *this; - } - - template - tuple_base &operator=(pair &&pair) { - do_move1<0, tuple_element_t<0, tuple>>(std::forward(pair.first)); - do_move1<1, tuple_element_t<1, tuple>>(std::forward(pair.second)); - return *this; - } - - template - int do_swap1(Tn &other) { - impl::tuple_elem &e = *this; - using std::swap; - swap(e.value, other); - return 0; - } - - void swap(tuple &other) { - ignore(do_swap1(get(other))...); - } -}; - -} -template -struct tuple : impl::tuple_base, Types...> { -private: - using base_type = impl::tuple_base, Types...>; - // Need this deferred so not evaluated in conjunction - // when size < 2 - template - struct is_pair_assignable : conjunction &, U1>, - is_assignable &, U2>> { }; - template - struct we_are_convertible_from : conjunction...> { }; - - template - struct we_are_constructible_from : conjunction...> { }; -public: - /* This would be simpler if ARM C 5 supported inheriting constructors, - * but as it doesn't, we need to repeat stuff here and in tuple_base. - */ - - /* C++17 form - conditional explicit idiom from N4387 */ - /* Default constructor, 0 args */ - template ...>::value, bool> = false> - constexpr tuple() : base_type() { } - /* Direct constructor, 1+ args */ - template = 1 && - conjunction...>::value && - we_are_convertible_from::value, bool> = false> - tuple(const Types &...args) : base_type(args...) { } - template = 1 && - conjunction...>::value && - !we_are_convertible_from::value, bool> = true> - explicit tuple(const Types &...args) : base_type(args...) { } - /* Converting constructor, 1+ args */ - template = 1 && - conjunction...>::value && - conjunction...>::value/*we_are_convertible_from::value*/, bool> = false> - tuple(UTypes &&...args) : base_type(std::forward(args)...) { } - template = 1 && - conjunction...>::value && - !conjunction...>::value/*we_are_convertible_from::value*/, bool> = true> - explicit tuple(UTypes &&...args) : base_type(std::forward(args)...) { } - /* Converting copy constructor */ - template , - is_constructible..., - disjunction, - conjunction &...>>, - negation &>...>>, - negation...>> - > - >, - conjunction...> - >::value, bool> = false> - tuple(const tuple &other) : base_type(other) { } - template , - is_constructible..., - disjunction, - conjunction &...>>, - negation &>...>>, - negation...>> - > - >, - negation...>> - >::value, bool> = true> - explicit tuple(const tuple &other) : base_type(other) { } - /* Converting move constructor */ - template , - is_constructible..., - disjunction, - conjunction...>>, - negation>...>>, - negation...>> - > - >, - conjunction...> - >::value, bool> = false> - tuple(tuple &&other) : base_type(std::forward>(other)) { } - template , - is_constructible..., - disjunction, - conjunction...>>, - negation>...>>, - negation...>> - > - >, - negation...>> - >::value, bool> = true> - explicit tuple(tuple &&other) : base_type(std::forward>(other)) { } - /* Converting pair copy constructor */ - template , - we_are_constructible_from, - we_are_convertible_from - >::value, bool> = false> - tuple(const pair &p) : base_type(p) { } - template , - we_are_constructible_from, - negation> - >::value, bool> = true> - explicit tuple(const pair &p) : base_type(p) { } - /* Converting pair move constructor */ - template , - we_are_constructible_from, - we_are_convertible_from - >::value, bool> = false> - tuple(pair &&p) : base_type(std::forward>(p)) { } - template , - we_are_constructible_from, - negation> - >::value, bool> = true> - explicit tuple(pair &&p) : base_type(std::forward>(p)) { } - - /* Copy and move constructors and assignments implicitly defined (only way to get default move in ARMC5) */ - - template , - conjunction...>>::value, int> = 0> - tuple &operator=(const tuple &other) { - *static_cast(this) = other; - return *this; - } - - template , - conjunction...>>::value, int> = 0> - tuple &operator=(tuple &&other) { - *static_cast(this) = std::move(other); - return *this; - } - - template , - is_pair_assignable>::value, int> = 0> - tuple &operator=(const pair &pair) { - *static_cast(this) = pair; - return *this; - } - - template , - is_pair_assignable>::value, int> = 0> - tuple &operator=(pair &&pair) { - *static_cast(this) = std::move(pair); - return *this; - } -}; - - - -namespace impl -{ -template -struct type_count : integral_constant { }; - -template -struct type_count : integral_constant::value + type_count::value> { }; - -template -struct type_find : integral_constant { }; - -template -struct type_find : conditional_t::value, integral_constant, type_find> { }; -} - - -template -struct tuple_size; - -template -struct tuple_size> : integral_constant { }; - -template -struct tuple_size : integral_constant::value> { }; - -template -struct tuple_size : integral_constant::value> { }; - -template -struct tuple_size : integral_constant::value> { }; - -template -tuple_element_t> &get(tuple &t) noexcept -{ - impl::tuple_elem>> &e = t; - return e.value; -} - -template -tuple_element_t> &&get(tuple &&t) noexcept -{ - impl::tuple_elem>> &&e = std::move(t); - return std::forward>>(e.value); -} - -template -const tuple_element_t> &get(const tuple &t) noexcept -{ - const impl::tuple_elem>> &e = t; - return e.value; -} - -template -const tuple_element_t> &&get(const tuple &&t) noexcept -{ - const impl::tuple_elem>> &&e = std::move(t); - return std::forward>>(e.value); -} - -template -T &get(tuple &t) noexcept -{ - static_assert(impl::type_count::value == 1, "not exactly 1 matching type in tuple"); - return get::value>(t); -} - -namespace impl{ -template -struct unwrap_ref_wrapper : type_identity { }; - -template -struct unwrap_ref_wrapper> : type_identity { }; - -template -struct tuple_decay : unwrap_ref_wrapper> { }; - -template -using tuple_decay_t = typename tuple_decay::type; -} - -template -tuple...> make_tuple(Types&&... args) -{ - return tuple...>(std::forward(args)...); -} - -template -tuple forward_as_tuple(Types&&... args) noexcept -{ - return tuple(std::forward(args)...); -} - -namespace impl { -struct ignore { - template - constexpr const ignore &operator=(const T &) const { return *this; } -}; -} - -const impl::ignore ignore; - -template -tuple tie(Types &... args) noexcept -{ - return tuple(args...); -} - -namespace impl -{ -template -struct tuple_cmp -{ - static bool equal(const T &t, const U &u) - { - return get(t) == get(u) ? tuple_cmp::equal(t, u) : false; - } - - static bool less(const T &t, const U &u) - { - return get(t) < get(u) ? true : - get(u) < get(t) ? false : - tuple_cmp::less(t, u); - } -}; - -template -struct tuple_cmp -{ - static bool equal(const T &t, const U &u) - { - return true; - } - - static bool less(const T &t, const U &u) - { - return false; - } -}; - -} - -template -bool operator==(const tuple &t, const tuple &u) -{ - static_assert(sizeof...(TTypes) == sizeof...(UTypes), "tuple size mismatch"); - return impl::tuple_cmp<0, sizeof...(TTypes), tuple, tuple>::equal(t, u); -} - -template -bool operator<(const tuple &t, const tuple &u) -{ - static_assert(sizeof...(TTypes) == sizeof...(UTypes), "tuple size mismatch"); - return impl::tuple_cmp<0, sizeof...(TTypes), tuple, tuple>::less(t, u); -} - -template -bool operator!=(const tuple &t, const tuple &u) -{ - return !(t == u); -} - -template -bool operator>(const tuple &t, const tuple &u) -{ - return u < t; -} - -template -bool operator<=(const tuple &t, const tuple &u) -{ - return !(u < t); -} -template -bool operator>=(const tuple &t, const tuple &u) -{ - return !(t < u); -} - -template -void swap(tuple &x, tuple &y) -{ - x.swap(y); -} - -// Start deep meta-programming for tuple_cat - -namespace impl { - -// List of types Ts... -template -struct mp_list { }; - -// Given A<...>, B, produce B<...> -template class B> -struct _mp_rename; - -template