mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Work-In-Progress for full implementation of etl::expected
fix set of ETL_NO_STL flag (#628) Co-authored-by: Sergey Skorokhod <s.skorokhod@1440.space> Removed duplicate include unique_ptr updates - Work in progress Updated versions & memory.h Fix duplicate function Fixed incorrect 'valid' flag in assignment operator for arithmetic specialisation Updated version and release notes Fix bug #636 in optional emplace for pod types (#638) Updated version info Updated generator test script Only build tests if top level project (#639) Removed trailing spaces Updated version info Incorrect C++03 enable_if syntax Updated version info Don't use `push_macro` and `pull_macro` with Tasking compiler (#643) * Autodetect Tasking compiler #642 * Don't use `push_macro` and `pop_macro` for Tasking compiler #642 Co-authored-by: Todd Snider <tsnider@jlg.com> #643 Don't use push_macro and pull_macro with Tasking compiler Updated etl::delgate to handle const functors correctly Updated version info Fixed functor delegate enable_if Updated release notes Avoid 'missing return statement at end of non-void function' in `etl::visit<>()`. (#645) * Avoid 'missing return statement at end of non-void function' in `etl::visit<>()`. For some definitions of `ETL_ASSERT()` there may be no return statement in case of an invalid type. This results in undefined behavior. Warning[Pe940]: missing return statement at end of non-void function "etl::visit<TReturn,TVisitor,TVariant>(TVisitor &, TVariant const &) include\etl\private\variant_legacy.h 976 * Use more self-explaining code. Substitute ET_ASSERT() and return by dedicated macro. This moves the responsibility of how to handle errors to the dedicated place. improve is_constructible, is_copy_constructible, is_move_constructible for type traits with default definitions (#648) Removed unused ETL_USE_MEM_BUILTINS option Updated version info Updated release notes Added etl::result<TValue, void> specialisation Reverted code for etl::result<void, TError> specialisation Added etl::result<TValue, void> specialisation Reverted code for etl::result<void, TError> specialisation Fixed perfect forwarding for make_xxx helper functions Don't warn on tag missing when subproject (#653) (#655) Different solution than proposed in the issue, since that proposed solution would given unexpected results when an intermediate (untagged) commit is checked out. This change simply skips warning about a missing git version when this is a subproject, and uses the original version calculation logic. I've also renamed `determine_version` to `determine_version_with_file`. I'd originally done this in an intermediate version of this PR, but I think that keeping the renaming is clearer code. Removed superfluous semicolons Updated version and release notes Removed testing for 18.04 Added testing for 22.04 Updated Github Actions for Clang Updated version and release notes clang updates for Github Actions Added missing notes emplace member functions return reference to emplaced value (#659) emplace_front, emplace_back updates Updated version and release info Improved emplace testing Changed unit test macro CHECK_FALSE_EQUAL to CHECK_NOT_EQUAL Improved emplace testing Changed unit test macro CHECK_FALSE_EQUAL to CHECK_NOT_EQUAL Improved emplace testing Work-In-Progress Work-In-Progress Added indexed emplace More typedefs for etl::result Work in progress Work in progress Work in progress Changed default constructor Added function comments
This commit is contained in:
parent
04bbf01938
commit
5fb3e4c2e6
38
.github/workflows/clang.yml
vendored
38
.github/workflows/clang.yml
vendored
@ -6,12 +6,12 @@ on:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build-clang-9-linux-stl:
|
||||
name: Clang-9 Linux - STL
|
||||
build-clang-linux-stl:
|
||||
name: Clang Linux - STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -19,9 +19,9 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y "clang-9" "lldb-9" "lld-9" "clang-format-9"
|
||||
export CC=clang-9
|
||||
export CXX=clang++-9
|
||||
sudo apt-get install -y "clang" "lldb" "lld" "clang-format"
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
|
||||
git fetch --tags
|
||||
cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF ./
|
||||
@ -31,12 +31,12 @@ jobs:
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
|
||||
build-clang-9-linux-no-stl:
|
||||
name: Clang-9 Linux - No STL
|
||||
build-clang-linux-no-stl:
|
||||
name: Clang Linux - No STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -44,26 +44,24 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y "clang-9" "lldb-9" "lld-9" "clang-format-9"
|
||||
export CC=clang-9
|
||||
export CXX=clang++-9
|
||||
sudo apt-get install -y "clang" "lldb" "lld" "clang-format"
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
|
||||
git fetch --tags
|
||||
cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF ./
|
||||
gcc --version
|
||||
cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF ./
|
||||
clang --version
|
||||
make
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
|
||||
build-clang-9-linux-stl-force-cpp03:
|
||||
name: Clang-9 Linux - STL - Force C++03
|
||||
build-clang-linux-stl-force-cpp03:
|
||||
name: Clang Linux - STL - Force C++03
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -71,9 +69,9 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y "clang-9" "lldb-9" "lld-9" "clang-format-9"
|
||||
export CC=clang-9
|
||||
export CXX=clang++-9
|
||||
sudo apt-get install -y "clang" "lldb" "lld" "clang-format"
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
|
||||
git fetch --tags
|
||||
cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON ./
|
||||
|
||||
6
.github/workflows/gcc.yml
vendored
6
.github/workflows/gcc.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, ubuntu-20.04]
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -32,7 +32,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, ubuntu-20.04]
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -53,7 +53,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, ubuntu-20.04]
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
@ -8,7 +8,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/helpers.cmake)
|
||||
set(MSG_PREFIX "etl |")
|
||||
determine_version_with_git(${GIT_DIR_LOOKUP_POLICY})
|
||||
if(NOT ETL_VERSION)
|
||||
determine_version("version.txt")
|
||||
determine_version_with_file("version.txt")
|
||||
endif()
|
||||
|
||||
project(etl VERSION ${ETL_VERSION} LANGUAGES CXX)
|
||||
@ -73,9 +73,9 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/etl DESTINATION include)
|
||||
endif()
|
||||
|
||||
if (BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
|
||||
if (BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library - Arduino",
|
||||
"version": "20.35.0",
|
||||
"version": "20.35.10",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library - Arduino
|
||||
version=20.35.0
|
||||
version=20.35.10
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
function(determine_version VER_FILE_NAME)
|
||||
function(determine_version_with_file VER_FILE_NAME)
|
||||
file(READ ${VER_FILE_NAME} ETL_VERSION_RAW)
|
||||
# Remove trailing whitespaces and/or newline
|
||||
string(STRIP ${ETL_VERSION_RAW} ETL_VERSION)
|
||||
@ -13,7 +13,11 @@ function(determine_version_with_git)
|
||||
git_describe(VERSION ${ARGN})
|
||||
string(FIND ${VERSION} "." VALID_VERSION)
|
||||
if(VALID_VERSION EQUAL -1)
|
||||
message(WARNING "Version string ${VERSION} retrieved with git describe is invalid")
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
# only warn if this is the top-level project, since we may be
|
||||
# building from a tarball as a subproject
|
||||
message(WARNING "Version string ${VERSION} retrieved with git describe is invalid")
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
message(STATUS "${MSG_PREFIX} Version string determined with git describe: ${VERSION}")
|
||||
|
||||
@ -40,7 +40,6 @@ SOFTWARE.
|
||||
#include "nullptr.h"
|
||||
#include "hash.h"
|
||||
#include "algorithm.h"
|
||||
#include "memory.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP11
|
||||
@ -155,7 +154,7 @@ namespace etl
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR array_view(etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR array_view(etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -165,7 +164,7 @@ namespace etl
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR array_view(const etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR array_view(const etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -215,7 +214,7 @@ namespace etl
|
||||
template <typename TContainer>
|
||||
ETL_CONSTEXPR array_view(TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
|
||||
!etl::is_array<TContainer>::value &&
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -228,7 +227,7 @@ namespace etl
|
||||
template <typename TContainer>
|
||||
ETL_CONSTEXPR array_view(const TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
|
||||
!etl::is_array<TContainer>::value &&
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
|
||||
@ -2198,7 +2198,7 @@ namespace etl
|
||||
|
||||
return (nbits == etl::integral_limits<type>::bits) ? static_cast<T>(etl::integral_limits<type>::max)
|
||||
: static_cast<T>((static_cast<type>(1U) << nbits) - 1U);
|
||||
};
|
||||
}
|
||||
|
||||
//***********************************
|
||||
template <typename T, size_t NBits>
|
||||
@ -2214,7 +2214,7 @@ namespace etl
|
||||
ETL_CONSTEXPR T make_msb_mask(size_t nbits)
|
||||
{
|
||||
return static_cast<T>(etl::reverse_bits(make_lsb_mask<T>(nbits)));
|
||||
};
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// 8 bit binary byte constants.
|
||||
|
||||
@ -33,7 +33,7 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#if ETL_USING_CPP11 && !defined(ETL_CRC_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_DELEGATE_FORCE_CPP03_IMPLEMENTATION)
|
||||
#include "private/delegate_cpp11.h"
|
||||
#else
|
||||
#include "private/delegate_cpp03.h"
|
||||
|
||||
@ -1742,7 +1742,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename ... Args>
|
||||
void emplace_back(Args && ... args)
|
||||
reference emplace_back(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1752,6 +1752,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
|
||||
#else
|
||||
@ -1761,7 +1762,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
void emplace_back(const T1& value1)
|
||||
reference emplace_back(const T1& value1)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1771,6 +1772,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1778,7 +1780,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_back(const T1& value1, const T2& value2)
|
||||
reference emplace_back(const T1& value1, const T2& value2)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1788,6 +1790,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1795,7 +1798,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1805,6 +1808,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1812,7 +1816,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1822,6 +1826,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1870,7 +1875,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename ... Args>
|
||||
void emplace_front(Args && ... args)
|
||||
reference emplace_front(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1880,6 +1885,7 @@ namespace etl
|
||||
::new (&(*_begin)) T(etl::forward<Args>(args)...);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return front();
|
||||
}
|
||||
|
||||
#else
|
||||
@ -1889,7 +1895,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
void emplace_front(const T1& value1)
|
||||
reference emplace_front(const T1& value1)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1899,6 +1905,7 @@ namespace etl
|
||||
::new (&(*_begin)) T(value1);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1906,7 +1913,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_front(const T1& value1, const T2& value2)
|
||||
reference emplace_front(const T1& value1, const T2& value2)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1916,6 +1923,7 @@ namespace etl
|
||||
::new (&(*_begin)) T(value1, value2);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1923,7 +1931,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace_front(const T1& value1, const T2& value2, const T3& value3)
|
||||
reference emplace_front(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1933,6 +1941,7 @@ namespace etl
|
||||
::new (&(*_begin)) T(value1, value2, value3);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1940,7 +1949,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
reference emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
@ -1950,6 +1959,7 @@ namespace etl
|
||||
::new (&(*_begin)) T(value1, value2, value3, value4);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return front();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -34,9 +34,53 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
#include "variant.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// Base exception for et::expected
|
||||
//***************************************************************************
|
||||
class expected_exception : public etl::exception
|
||||
{
|
||||
public:
|
||||
|
||||
expected_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// expected_invalid
|
||||
//***************************************************************************
|
||||
template <typename TError>
|
||||
class expected_invalid;
|
||||
|
||||
//*******************************************
|
||||
template<>
|
||||
class expected_invalid<void> : public etl::expected_exception
|
||||
{
|
||||
public:
|
||||
|
||||
expected_invalid(string_type file_name_, numeric_type line_number_)
|
||||
: expected_exception(ETL_ERROR_TEXT("expected:invalid", ETL_EXPECTED_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*******************************************
|
||||
template <typename TError>
|
||||
class expected_invalid : etl::expected_invalid<void>
|
||||
{
|
||||
public:
|
||||
|
||||
expected_invalid(string_type file_name_, numeric_type line_number_)
|
||||
: expected_invalid<void>(file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Unexpected type.
|
||||
/// etl::unexpected represents an unexpected value stored in etl::expected.
|
||||
@ -46,6 +90,8 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef TError error_type;
|
||||
|
||||
//*******************************************
|
||||
/// Copy constructor.
|
||||
//*******************************************
|
||||
@ -114,8 +160,9 @@ namespace etl
|
||||
ETL_CONSTEXPR14
|
||||
etl::unexpected<TError>& operator =(const etl::unexpected<TError>& rhs)
|
||||
{
|
||||
error_value = rhs.error_value;
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TError>::value, "Error not copy assignable");
|
||||
|
||||
error_value = rhs.error_value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -126,8 +173,9 @@ namespace etl
|
||||
ETL_CONSTEXPR14
|
||||
etl::unexpected<TError>& operator =(etl::unexpected<TError>&& rhs)
|
||||
{
|
||||
error_value = etl::move(rhs.error_value);
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TError>::value, "Error not move assignable");
|
||||
|
||||
error_value = etl::move(rhs.error_value);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@ -136,7 +184,7 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr const TError& error() const& noexcept
|
||||
constexpr TError& error() & noexcept
|
||||
{
|
||||
return error_value;
|
||||
}
|
||||
@ -144,16 +192,7 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr const TError&& error() const&& noexcept
|
||||
{
|
||||
return etl::move(error_value);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP14
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
constexpr TError& error() & noexcept
|
||||
constexpr const TError& error() const& noexcept
|
||||
{
|
||||
return error_value;
|
||||
}
|
||||
@ -165,24 +204,14 @@ namespace etl
|
||||
{
|
||||
return etl::move(error_value);
|
||||
}
|
||||
#else
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
TError& error() & noexcept
|
||||
{
|
||||
return error_value;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
//*******************************************
|
||||
TError&& error() && noexcept
|
||||
constexpr TError&& error() const && noexcept
|
||||
{
|
||||
return etl::move(error_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
//*******************************************
|
||||
/// Get the error.
|
||||
@ -210,8 +239,604 @@ namespace etl
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
template <typename TError>
|
||||
unexpected(TError) -> unexpected<TError>;
|
||||
bool operator ==(const etl::unexpected<TError>& lhs, const etl::unexpected<TError>& rhs)
|
||||
{
|
||||
return lhs.error_value == rhs.error_value;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Swap etl::unexpected.
|
||||
//*******************************************
|
||||
template <typename TError>
|
||||
void swap(etl::unexpected<TError>& lhs, etl::unexpected<TError>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
/// unexpect_t
|
||||
//*****************************************************************************
|
||||
struct unexpect_t
|
||||
{
|
||||
ETL_CONSTEXPR14 explicit unexpect_t()
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
inline constexpr unexpect_t unexpect{};
|
||||
#else
|
||||
static const unexpect_t unexpect;
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
/// Expected type.
|
||||
//*****************************************************************************
|
||||
template <typename TValue, typename TError>
|
||||
class expected
|
||||
{
|
||||
public:
|
||||
|
||||
typedef etl::expected<TValue, TError> this_type;
|
||||
typedef TValue value_type;
|
||||
typedef TError error_type;
|
||||
typedef etl::unexpected<TError> unexpected_type;
|
||||
|
||||
template <typename U>
|
||||
using rebind = expected<U, TError>;
|
||||
|
||||
//*******************************************
|
||||
/// Default constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected() ETL_NOEXCEPT
|
||||
: storage(etl::in_place_index<Value_Type>, value_type())
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected(const value_type& value_) ETL_NOEXCEPT
|
||||
: storage(etl::in_place_index<Value_Type>, value_)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected(value_type&& value_) ETL_NOEXCEPT
|
||||
: storage(etl::in_place_index<Value_Type>, etl::move(value_))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected(const expected& other) ETL_NOEXCEPT
|
||||
: storage(other.storage)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 expected(expected&& other) ETL_NOEXCEPT
|
||||
: storage(etl::move(other.storage))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy construct from unexpected type.
|
||||
//*******************************************
|
||||
template <typename F>
|
||||
ETL_CONSTEXPR14 explicit expected(const etl::unexpected<F>& ue)
|
||||
: storage(etl::in_place_index<Error_Type>, ue.error())
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move construct from unexpected type.
|
||||
//*******************************************
|
||||
template <typename F>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::unexpected<F>&& ue)
|
||||
: storage(etl::in_place_index<Error_Type>, etl::move(ue.error()))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct with default value type.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 explicit expected(etl::in_place_t) ETL_NOEXCEPT
|
||||
: storage(value_type())
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct value type from arguments.
|
||||
//*******************************************
|
||||
template <typename... Args>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::in_place_t, Args&&... args)
|
||||
: storage(etl::forward<Args>(args)...)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct value type from initializser_list and arguments.
|
||||
//*******************************************
|
||||
template <typename U, typename... Args>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::in_place_t, std::initializer_list<U> il, Args&&... args)
|
||||
: storage(il, etl::forward<Args>(args)...)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct error type from arguments.
|
||||
//*******************************************
|
||||
template <typename... Args>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::unexpect_t, Args&&... args)
|
||||
: storage(error_type(etl::forward<Args>(args)...))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct error type from initializser_list and arguments.
|
||||
//*******************************************
|
||||
template <typename U, typename... Args>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::unexpect_t, std::initializer_list<U> il, Args&&... args)
|
||||
: storage(error_type(il, etl::forward<Args>(args)...))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
this_type& operator =(const this_type& other)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TValue>::value && etl::is_copy_constructible<TError>::value, "Not copy assignable");
|
||||
|
||||
storage = other.storage;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
this_type& operator =(this_type&& other)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TValue>::value && etl::is_move_constructible<TError>::value, "Not move assignable");
|
||||
|
||||
storage = etl::move(other.storage);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from value
|
||||
//*******************************************
|
||||
expected& operator =(const value_type& value)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TValue>::value, "Value not copy assignable");
|
||||
|
||||
storage.emplace<Value_Type>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move assign from value
|
||||
//*******************************************
|
||||
expected& operator =(value_type&& value)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TValue>::value, "Value not move assignable");
|
||||
|
||||
storage.emplace<Value_Type>(etl::move(value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from error
|
||||
//*******************************************
|
||||
expected& operator =(const unexpected_type& error)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TError>::value, "Error not copy assignable");
|
||||
|
||||
storage.emplace<Error_Type>(error);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move assign from error
|
||||
//*******************************************
|
||||
expected& operator =(unexpected_type&& error)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TError>::value, "Error not move assignable");
|
||||
|
||||
storage.emplace<Error_Type>(etl::move(error));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 value_type& value()&
|
||||
{
|
||||
return etl::get<Value_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 const value_type& value() const&
|
||||
{
|
||||
return etl::get<Value_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 value_type&& value()&&
|
||||
{
|
||||
return etl::move(etl::get<Value_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 const value_type&& value() const&&
|
||||
{
|
||||
return etl::move(etl::get<Value_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool has_value() const
|
||||
{
|
||||
return (storage.index() == Value_Type);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
operator bool() const
|
||||
{
|
||||
return has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
value_type value_or(U&& default_value) const&
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return value();
|
||||
}
|
||||
else
|
||||
{
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename U>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
value_type value_or(U&& default_value)&&
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return etl::move(value());
|
||||
}
|
||||
else
|
||||
{
|
||||
return etl::move(default_value);
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
error_type& error()& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const error_type& error() const& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
error_type&& error() && ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const error_type&& error() const&& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename... Args>
|
||||
ETL_CONSTEXPR14 value_type& emplace(Args&&... args) ETL_NOEXCEPT
|
||||
{
|
||||
storage.emplace(args...);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
template <typename U, typename... Args>
|
||||
ETL_CONSTEXPR14 value_type& emplace(std::initializer_list<U>& il, Args&&... args) ETL_NOEXCEPT
|
||||
{
|
||||
storage.emplace(il, args...);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
value_type* operator ->()
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(expected_invalid));
|
||||
#endif
|
||||
|
||||
return etl::addressof(storage.get<Value_Type>());
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
const value_type* operator ->() const
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(expected_invalid));
|
||||
#endif
|
||||
|
||||
return etl::addressof(storage.get<Value_Type>());
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
value_type& operator *()
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(expected_invalid));
|
||||
#endif
|
||||
|
||||
return storage.get<Value_Type>();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
///
|
||||
//*******************************************
|
||||
const value_type& operator *() const
|
||||
{
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(valid, ETL_ERROR(expected_invalid));
|
||||
#endif
|
||||
|
||||
return storage.get<Value_Type>();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
Uninitialised,
|
||||
Value_Type,
|
||||
Error_Type
|
||||
};
|
||||
|
||||
using storage_type = etl::variant<etl::monostate, value_type, error_type>;
|
||||
storage_type storage;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Specialisation for void value type.
|
||||
//*****************************************************************************
|
||||
template<typename TError>
|
||||
class expected<void, TError>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef etl::expected<void, TError> this_type;
|
||||
typedef void value_type;
|
||||
typedef TError error_type;
|
||||
typedef etl::unexpected<TError> unexpected_type;
|
||||
|
||||
//*******************************************
|
||||
/// Default constructor
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected()
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy construct from unexpected
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected(const unexpected_type& ue_)
|
||||
: storage(ue_.error())
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move construct from unexpected
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected(unexpected_type&& ue_)
|
||||
: storage(etl::move(ue_.error()))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy construct
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected(const this_type& other)
|
||||
: storage(other.storage)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move construct
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
expected(this_type&& other)
|
||||
: storage(etl::move(other.storage))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign
|
||||
//*******************************************
|
||||
this_type& operator =(const this_type& other)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TError>::value, "Not copy assignable");
|
||||
|
||||
storage = other.storage;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move assign
|
||||
//*******************************************
|
||||
this_type& operator =(this_type&& other)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TError>::value, "Not move assignable");
|
||||
|
||||
storage = etl::move(other.storage);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from error
|
||||
//*******************************************
|
||||
expected& operator =(const unexpected_type& error)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_copy_constructible<TError>::value, "Error not copy assignable");
|
||||
|
||||
storage.emplace<Error_Type>(error);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move assign from error
|
||||
//*******************************************
|
||||
expected& operator =(unexpected_type&& error)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_move_constructible<TError>::value, "Error not move assignable");
|
||||
|
||||
storage.emplace<Error_Type>(etl::move(error));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns true if expected has a value
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool has_value() const
|
||||
{
|
||||
return (storage.index() != Error_Type);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns true if expected has a value
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
operator bool() const
|
||||
{
|
||||
return has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
error_type& error()& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const error_type& error() const& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
error_type&& error() && ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
/// Undefined behaviour if an error has not been set.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const error_type&& error() const&& ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
Uninitialised,
|
||||
Error_Type
|
||||
};
|
||||
|
||||
etl::variant<etl::monostate, error_type> storage;
|
||||
};
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -234,20 +859,4 @@ void swap(etl::unexpected<TError>& lhs, etl::unexpected<TError>& rhs)
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
/// unexpect_t
|
||||
//*****************************************************************************
|
||||
struct unexpect_t
|
||||
{
|
||||
ETL_CONSTEXPR14 explicit unexpect_t()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
inline constexpr unexpect_t unexpect{};
|
||||
#else
|
||||
static const unexpect_t unexpect;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -722,7 +722,7 @@ namespace etl
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
template <typename ... Args>
|
||||
void emplace_front(Args && ... args)
|
||||
reference emplace_front(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
|
||||
@ -731,13 +731,14 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
return front();
|
||||
}
|
||||
#else
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
void emplace_front(const T1& value1)
|
||||
reference emplace_front(const T1& value1)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
|
||||
@ -746,13 +747,14 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_front(const T1& value1, const T2& value2)
|
||||
reference emplace_front(const T1& value1, const T2& value2)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
|
||||
@ -761,13 +763,14 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace_front(const T1& value1, const T2& value2, const T3& value3)
|
||||
reference emplace_front(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
|
||||
@ -776,13 +779,14 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
reference emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
|
||||
@ -791,6 +795,7 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
return front();
|
||||
}
|
||||
#endif // ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
|
||||
|
||||
@ -1756,7 +1761,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
#if ETL_USING_CPP11 && ETL_HAS_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_forward_list(T... t) -> etl::forward_list<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
constexpr auto make_forward_list(T&&... t) -> etl::forward_list<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
|
||||
@ -714,7 +714,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// is_enum
|
||||
///\ingroup type_traits
|
||||
/// Implemented by checking if type is convertable to an integer thru static_cast
|
||||
/// Implemented by checking if type is convertible to an integer through static_cast
|
||||
|
||||
namespace private_type_traits
|
||||
{
|
||||
@ -1988,13 +1988,40 @@ namespace etl
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// is_constructible
|
||||
namespace private_type_traits
|
||||
{
|
||||
template <class, class T, class... Args>
|
||||
struct is_constructible_ : etl::false_type {};
|
||||
|
||||
template <class T, class... Args>
|
||||
struct is_constructible_<void_t<decltype(T(etl::declval<Args>()...))>, T, Args...> : etl::true_type {};
|
||||
};
|
||||
|
||||
|
||||
//*********************************************
|
||||
// is_constructible
|
||||
template <typename T, typename... TArgs>
|
||||
struct is_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
|
||||
{
|
||||
};
|
||||
#endif
|
||||
template <class T, class... Args>
|
||||
using is_constructible = private_type_traits::is_constructible_<void_t<>, T, Args...>;
|
||||
|
||||
//*********************************************
|
||||
// is_copy_constructible
|
||||
template <class T> struct is_copy_constructible : public is_constructible<T, typename etl::add_lvalue_reference<typename etl::add_const<T>::type>::type>{};
|
||||
template <> struct is_copy_constructible<void> : public false_type{};
|
||||
template <> struct is_copy_constructible<void const> : public false_type{};
|
||||
template <> struct is_copy_constructible<void volatile> : public false_type{};
|
||||
template <> struct is_copy_constructible<void const volatile> : public false_type{};
|
||||
|
||||
//*********************************************
|
||||
// is_move_constructible
|
||||
template <typename T> struct is_move_constructible: public is_constructible<T, typename etl::add_rvalue_reference<T>::type>{};
|
||||
template <> struct is_move_constructible<void> : public false_type{};
|
||||
template <> struct is_move_constructible<void const> : public false_type{};
|
||||
template <> struct is_move_constructible<void volatile> : public false_type{};
|
||||
template <> struct is_move_constructible<void const volatile> : public false_type{};
|
||||
|
||||
#else
|
||||
|
||||
//*********************************************
|
||||
// is_copy_constructible
|
||||
@ -2009,6 +2036,7 @@ namespace etl
|
||||
struct is_move_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
//*********************************************
|
||||
// is_trivially_constructible
|
||||
|
||||
@ -782,10 +782,11 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename ... Args>
|
||||
void emplace_back(Args && ... args)
|
||||
reference emplace_back(Args && ... args)
|
||||
{
|
||||
T* p = storage.create<T>(etl::forward<Args>(args)...);
|
||||
lookup.push_back(p);
|
||||
return back();
|
||||
}
|
||||
#else
|
||||
//*********************************************************************
|
||||
@ -794,10 +795,11 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1>
|
||||
void emplace_back(const T1& value1)
|
||||
reference emplace_back(const T1& value1)
|
||||
{
|
||||
T* p = storage.create<T>(T(value1));
|
||||
lookup.push_back(p);
|
||||
return back();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -806,10 +808,11 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_back(const T1& value1, const T2& value2)
|
||||
reference emplace_back(const T1& value1, const T2& value2)
|
||||
{
|
||||
T* p = storage.create<T>(T(value1, value2));
|
||||
lookup.push_back(p);
|
||||
return back();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -818,10 +821,11 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
T* p = storage.create<T>(T(value1, value2, value3));
|
||||
lookup.push_back(p);
|
||||
return back();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -830,10 +834,11 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
T* p = storage.create<T>(T(value1, value2, value3, value4));
|
||||
lookup.push_back(p);
|
||||
return back();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1433,7 +1438,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
#if ETL_USING_CPP11 && ETL_HAS_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_indirect_vector(T... t) -> etl::indirect_vector<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
constexpr auto make_indirect_vector(T&&... t) -> etl::indirect_vector<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
|
||||
@ -862,7 +862,7 @@ namespace etl
|
||||
/// Emplaces a value to the front of the list.
|
||||
//*************************************************************************
|
||||
template <typename ... Args>
|
||||
void emplace_front(Args && ... args)
|
||||
reference emplace_front(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -873,13 +873,14 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
return front();
|
||||
}
|
||||
#else
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
void emplace_front(const T1& value1)
|
||||
reference emplace_front(const T1& value1)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -890,13 +891,14 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_front(const T1& value1, const T2& value2)
|
||||
reference emplace_front(const T1& value1, const T2& value2)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -907,13 +909,14 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace_front(const T1& value1, const T2& value2, const T3& value3)
|
||||
reference emplace_front(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -924,13 +927,14 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
return front();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
reference emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -941,6 +945,7 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
return front();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -985,7 +990,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
|
||||
template <typename ... Args>
|
||||
void emplace_back(Args && ... args)
|
||||
reference emplace_back(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -996,10 +1001,11 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
return back();
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace_back(const T1& value1)
|
||||
reference emplace_back(const T1& value1)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -1010,10 +1016,11 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
return back();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void emplace_back(const T1& value1, const T2& value2)
|
||||
reference emplace_back(const T1& value1, const T2& value2)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -1024,10 +1031,11 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
return back();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -1038,10 +1046,11 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
return back();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
@ -1052,6 +1061,7 @@ namespace etl
|
||||
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
return back();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ SOFTWARE.
|
||||
#include "nullptr.h"
|
||||
#include "alignment.h"
|
||||
#include "placement_new.h"
|
||||
|
||||
#include "private/addressof.h"
|
||||
|
||||
#include <assert.h>
|
||||
@ -1231,7 +1232,19 @@ namespace etl
|
||||
template <typename T>
|
||||
struct default_delete
|
||||
{
|
||||
void operator()(T* p) const
|
||||
//*********************************
|
||||
ETL_CONSTEXPR default_delete() ETL_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename U>
|
||||
default_delete(const default_delete<U>&) ETL_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
void operator()(T * p) const ETL_NOEXCEPT
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
@ -1246,6 +1259,18 @@ namespace etl
|
||||
template <typename T>
|
||||
struct default_delete<T[]>
|
||||
{
|
||||
//*********************************
|
||||
ETL_CONSTEXPR default_delete() ETL_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename U>
|
||||
default_delete(const default_delete<U>&) ETL_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <class U>
|
||||
void operator()(U* p) const
|
||||
{
|
||||
@ -1282,10 +1307,23 @@ namespace etl
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*********************************
|
||||
unique_ptr(unique_ptr&& p_) ETL_NOEXCEPT
|
||||
: p(p_.release())
|
||||
, deleter(etl::move(p_.deleter))
|
||||
unique_ptr(unique_ptr&& other) ETL_NOEXCEPT
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
p = other.release();
|
||||
deleter = etl::move(other.deleter);
|
||||
}
|
||||
}
|
||||
#else
|
||||
//*********************************
|
||||
unique_ptr(unique_ptr& other) ETL_NOEXCEPT
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
p = other.release();
|
||||
deleter = other.deleter;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1305,6 +1343,13 @@ namespace etl
|
||||
, deleter(etl::move(deleter_))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U, typename E>
|
||||
unique_ptr(unique_ptr<U, E>&& u) ETL_NOEXCEPT
|
||||
: p(u.release())
|
||||
, deleter(etl::forward<E>(u.get_deleter()))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************
|
||||
@ -1387,9 +1432,25 @@ namespace etl
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*********************************
|
||||
unique_ptr& operator =(unique_ptr&& p_) ETL_NOEXCEPT
|
||||
unique_ptr& operator =(unique_ptr&& other) ETL_NOEXCEPT
|
||||
{
|
||||
reset(p_.release());
|
||||
if (&other != this)
|
||||
{
|
||||
reset(other.release());
|
||||
deleter = etl::move(other.deleter);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
//*********************************
|
||||
unique_ptr& operator =(unique_ptr& other) ETL_NOEXCEPT
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
reset(other.release());
|
||||
deleter = other.deleter;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -1439,7 +1500,7 @@ namespace etl
|
||||
typedef T& reference;
|
||||
|
||||
//*********************************
|
||||
ETL_CONSTEXPR unique_ptr() ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR unique_ptr() ETL_NOEXCEPT
|
||||
: p(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
@ -1452,17 +1513,31 @@ namespace etl
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*********************************
|
||||
unique_ptr(unique_ptr&& p_) ETL_NOEXCEPT
|
||||
: p(p_.release())
|
||||
, deleter(etl::move(p_.deleter))
|
||||
unique_ptr(unique_ptr&& other) ETL_NOEXCEPT
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
p = other.release();
|
||||
deleter = etl::move(other.deleter);
|
||||
}
|
||||
}
|
||||
#else
|
||||
//*********************************
|
||||
unique_ptr(unique_ptr& other) ETL_NOEXCEPT
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
p = other.release();
|
||||
deleter = other.deleter;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************
|
||||
unique_ptr(pointer p_, typename etl::conditional<etl::is_reference<TDeleter>::value,
|
||||
TDeleter,
|
||||
typename etl::add_lvalue_reference<const TDeleter>::type>::type deleter_) ETL_NOEXCEPT
|
||||
unique_ptr(pointer p_,
|
||||
typename etl::conditional<etl::is_reference<TDeleter>::value,
|
||||
TDeleter,
|
||||
typename etl::add_lvalue_reference<const TDeleter>::type>::type deleter_) ETL_NOEXCEPT
|
||||
: p(p_)
|
||||
, deleter(deleter_)
|
||||
{
|
||||
@ -1475,6 +1550,13 @@ namespace etl
|
||||
, deleter(etl::move(deleter_))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U, typename E>
|
||||
unique_ptr(unique_ptr<U, E>&& u) ETL_NOEXCEPT
|
||||
: p(u.release())
|
||||
, deleter(etl::forward<E>(u.get_deleter()))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************
|
||||
@ -1556,9 +1638,25 @@ namespace etl
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//*********************************
|
||||
unique_ptr& operator =(unique_ptr&& p_) ETL_NOEXCEPT
|
||||
unique_ptr& operator =(unique_ptr&& other) ETL_NOEXCEPT
|
||||
{
|
||||
reset(p_.release());
|
||||
if (&other != this)
|
||||
{
|
||||
reset(other.release());
|
||||
deleter = etl::move(other.deleter);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
//*********************************
|
||||
unique_ptr& operator =(unique_ptr& other) ETL_NOEXCEPT
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
reset(other.release());
|
||||
deleter = other.deleter;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -427,7 +427,7 @@ namespace etl
|
||||
///\param args The arguments to construct with.
|
||||
//*************************************************************************
|
||||
template <typename ... Args>
|
||||
void emplace(Args && ... args)
|
||||
T& emplace(Args && ... args)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
@ -437,6 +437,7 @@ namespace etl
|
||||
|
||||
::new (storage.template get_address<T>()) T(ETL_OR_STD::forward<Args>(args)...);
|
||||
valid = true;
|
||||
return storage;
|
||||
}
|
||||
#else
|
||||
//*************************************************************************
|
||||
@ -444,7 +445,7 @@ namespace etl
|
||||
/// 1 parameter.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
void emplace(const T1& value1)
|
||||
T& emplace(const T1& value1)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
@ -454,6 +455,7 @@ namespace etl
|
||||
|
||||
::new (storage.template get_address<T>()) T(value1);
|
||||
valid = true;
|
||||
return storage;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -461,7 +463,7 @@ namespace etl
|
||||
/// 2 parameters.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace(const T1& value1, const T2& value2)
|
||||
T& emplace(const T1& value1, const T2& value2)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
@ -471,6 +473,7 @@ namespace etl
|
||||
|
||||
::new (storage.template get_address<T>()) T(value1, value2);
|
||||
valid = true;
|
||||
return storage;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -478,7 +481,7 @@ namespace etl
|
||||
/// 3 parameters.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace(const T1& value1, const T2& value2, const T3& value3)
|
||||
T& emplace(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
@ -488,6 +491,7 @@ namespace etl
|
||||
|
||||
::new (storage.template get_address<T>()) T(value1, value2, value3);
|
||||
valid = true;
|
||||
return storage;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -495,7 +499,7 @@ namespace etl
|
||||
/// 4 parameters.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
T& emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
@ -505,6 +509,7 @@ namespace etl
|
||||
|
||||
::new (storage.template get_address<T>()) T(value1, value2, value3, value4);
|
||||
valid = true;
|
||||
return storage;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -613,7 +618,7 @@ namespace etl
|
||||
if (this != &other)
|
||||
{
|
||||
storage = etl::move(other.storage);
|
||||
valid = true;
|
||||
valid = other.valid;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -766,12 +771,6 @@ namespace etl
|
||||
template <typename ... Args>
|
||||
ETL_CONSTEXPR14 void emplace(Args && ... args)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
// Destroy the old one.
|
||||
storage.template get_reference<T>().~T();
|
||||
}
|
||||
|
||||
storage = T(ETL_OR_STD::forward<Args>(args)...);
|
||||
valid = true;
|
||||
}
|
||||
|
||||
@ -174,11 +174,13 @@ namespace etl
|
||||
template <typename T>
|
||||
class delegate;
|
||||
|
||||
|
||||
|
||||
template <typename TReturn, typename TParam>
|
||||
class delegate<TReturn(TParam)> : public private_delegate::call_if_impl<delegate<TReturn(TParam)>, TReturn, TParam>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef delegate<TReturn(TParam)> delegate_type;
|
||||
|
||||
public:
|
||||
|
||||
using private_delegate::call_if_impl<delegate<TReturn(TParam)>, TReturn, TParam>::call_if;
|
||||
@ -202,11 +204,20 @@ namespace etl
|
||||
// Construct from a functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
delegate(const TFunctor& instance)
|
||||
delegate(TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, int>::type = 0)
|
||||
{
|
||||
assign((void*)(&instance), functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Construct from a const functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
delegate(const TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, int>::type = 0)
|
||||
{
|
||||
assign((void*)(&instance), const_functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from function (Compile time).
|
||||
//*************************************************************************
|
||||
@ -221,12 +232,23 @@ namespace etl
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
static
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value, delegate>::type
|
||||
create(const TFunctor& instance)
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value &&!etl::is_same<delegate_type, TFunctor>::value, delegate>::type
|
||||
create(TFunctor& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from a const Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
static
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
|
||||
create(const TFunctor& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), const_functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from instance method (Run time).
|
||||
//*************************************************************************
|
||||
@ -273,15 +295,25 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set from Lambda or Functor.
|
||||
/// Set from Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value, void>::type
|
||||
set(const TFunctor& instance)
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void>::type
|
||||
set(TFunctor& instance)
|
||||
{
|
||||
assign((void*)(&instance), functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set from const Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void>::type
|
||||
set(const TFunctor& instance)
|
||||
{
|
||||
assign((void*)(&instance), const_functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set from instance method (Run time).
|
||||
//*************************************************************************
|
||||
@ -384,16 +416,27 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from Lambda or Functor.
|
||||
/// Create from Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value, delegate&>::type
|
||||
operator =(const TFunctor& instance)
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
|
||||
operator =(TFunctor& instance)
|
||||
{
|
||||
assign((void*)(&instance), functor_stub<TFunctor>);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from const Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
|
||||
operator =(const TFunctor& instance)
|
||||
{
|
||||
assign((void*)(&instance), const_functor_stub<TFunctor>);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks equality.
|
||||
//*************************************************************************
|
||||
@ -549,7 +592,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a lambda or functor function.
|
||||
/// Stub call for a functor function.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
static TReturn functor_stub(void* object, TParam param)
|
||||
@ -558,6 +601,16 @@ namespace etl
|
||||
return (p->operator())(param);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a functor function.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
static TReturn const_functor_stub(void* object, TParam param)
|
||||
{
|
||||
const TFunctor* p = static_cast<const TFunctor*>(object);
|
||||
return (p->operator())(param);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// The invocation object.
|
||||
//*************************************************************************
|
||||
@ -568,9 +621,12 @@ namespace etl
|
||||
/// Specialisation for void parameter.
|
||||
//*************************************************************************
|
||||
template <typename TReturn>
|
||||
class delegate<TReturn(void)>
|
||||
: public private_delegate::call_if_impl<delegate<TReturn(void)>, TReturn, void>
|
||||
class delegate<TReturn(void)> : public private_delegate::call_if_impl<delegate<TReturn(void)>, TReturn, void>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef delegate<TReturn(void)> delegate_type;
|
||||
|
||||
public:
|
||||
|
||||
using private_delegate::call_if_impl< delegate<TReturn(void)>, TReturn, void>::call_if;
|
||||
@ -591,14 +647,23 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Construct from lambda or functor.
|
||||
// Construct from functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
delegate(const TFunctor& instance)
|
||||
delegate(TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, int>::type = 0)
|
||||
{
|
||||
assign((void*)(&instance), functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Construct from const functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
delegate(const TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, int>::type = 0)
|
||||
{
|
||||
assign((void*)(&instance), const_functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from function (Compile time).
|
||||
//*************************************************************************
|
||||
@ -609,16 +674,27 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from Lambda or Functor.
|
||||
/// Create from Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
static
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value, delegate>::type
|
||||
create(const TFunctor& instance)
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
|
||||
create(TFunctor& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from const Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
static
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
|
||||
create(const TFunctor& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), const_functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from instance method (Run time).
|
||||
//*************************************************************************
|
||||
@ -665,15 +741,25 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set from Lambda or Functor.
|
||||
/// Set from Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value, void>::type
|
||||
set(const TFunctor& instance)
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void>::type
|
||||
set(TFunctor& instance)
|
||||
{
|
||||
assign((void*)(&instance), functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set from const Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void>::type
|
||||
set(const TFunctor& instance)
|
||||
{
|
||||
assign((void*)(&instance), const_functor_stub<TFunctor>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set from instance method (Run time).
|
||||
//*************************************************************************
|
||||
@ -776,16 +862,27 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from Lambda or Functor.
|
||||
/// Create from Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value, delegate&>::type
|
||||
operator =(const TFunctor& instance)
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
|
||||
operator =(TFunctor& instance)
|
||||
{
|
||||
assign((void*)(&instance), functor_stub<TFunctor>);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from const Functor.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
|
||||
operator =(const TFunctor& instance)
|
||||
{
|
||||
assign((void*)(&instance), const_functor_stub<TFunctor>);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks equality.
|
||||
//*************************************************************************
|
||||
@ -941,7 +1038,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a lambda or functor function.
|
||||
/// Stub call for a functor function.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
static TReturn functor_stub(void* object)
|
||||
@ -950,6 +1047,16 @@ namespace etl
|
||||
return (p->operator())();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a const functor function.
|
||||
//*************************************************************************
|
||||
template <typename TFunctor>
|
||||
static TReturn const_functor_stub(void* object)
|
||||
{
|
||||
const TFunctor* p = static_cast<const TFunctor*>(object);
|
||||
return (p->operator())();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// The invocation object.
|
||||
//*************************************************************************
|
||||
|
||||
@ -111,12 +111,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Construct from lambda or functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 delegate(const TLambda& instance)
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 delegate(TLambda& instance)
|
||||
{
|
||||
assign((void*)(&instance), lambda_stub<TLambda>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Construct from const lambda or functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 delegate(const TLambda& instance)
|
||||
{
|
||||
assign((void*)(&instance), const_lambda_stub<TLambda>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from function (Compile time).
|
||||
//*************************************************************************
|
||||
@ -130,13 +139,23 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Create from Lambda or Functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value, void>>
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
|
||||
ETL_NODISCARD
|
||||
static ETL_CONSTEXPR14 delegate create(const TLambda& instance)
|
||||
static ETL_CONSTEXPR14 delegate create(TLambda& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), lambda_stub<TLambda>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from const Lambda or Functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
|
||||
ETL_NODISCARD
|
||||
static ETL_CONSTEXPR14 delegate create(const TLambda& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), const_lambda_stub<TLambda>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from instance method (Run time).
|
||||
//*************************************************************************
|
||||
@ -203,12 +222,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Set from Lambda or Functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 void set(const TLambda& instance)
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 void set(TLambda& instance)
|
||||
{
|
||||
assign((void*)(&instance), lambda_stub<TLambda>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set from const Lambda or Functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 void set(const TLambda& instance)
|
||||
{
|
||||
assign((void*)(&instance), const_lambda_stub<TLambda>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set from instance method (Run time).
|
||||
//*************************************************************************
|
||||
@ -347,13 +375,23 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Create from Lambda or Functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 delegate& operator =(const TLambda& instance)
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 delegate& operator =(TLambda& instance)
|
||||
{
|
||||
assign((void*)(&instance), lambda_stub<TLambda>);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from const Lambda or Functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value && !etl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value, void>>
|
||||
ETL_CONSTEXPR14 delegate& operator =(const TLambda& instance)
|
||||
{
|
||||
assign((void*)(&instance), const_lambda_stub<TLambda>);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks equality.
|
||||
//*************************************************************************
|
||||
@ -517,6 +555,16 @@ namespace etl
|
||||
return (p->operator())(etl::forward<TParams>(arg)...);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a const lambda or functor function.
|
||||
//*************************************************************************
|
||||
template <typename TLambda>
|
||||
static ETL_CONSTEXPR14 TReturn const_lambda_stub(void* object, TParams... arg)
|
||||
{
|
||||
const TLambda* p = static_cast<const TLambda*>(object);
|
||||
return (p->operator())(etl::forward<TParams>(arg)...);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// The invocation object.
|
||||
//*************************************************************************
|
||||
|
||||
@ -354,9 +354,11 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
void emplace_back(parameter_t value)
|
||||
reference emplace_back(parameter_t value)
|
||||
{
|
||||
base_t::emplace_back(value);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -32,7 +32,7 @@ SOFTWARE.
|
||||
* The header include guard has been intentionally omitted.
|
||||
* This file is intended to evaluated multiple times by design.
|
||||
*/
|
||||
#if !defined(ETL_COMPILER_GREEN_HILLS) && !defined(ETL_COMPILER_IAR)
|
||||
#if !defined(ETL_COMPILER_GREEN_HILLS) && !defined(ETL_COMPILER_IAR) && !defined(ETL_COMPILER_TASKING)
|
||||
#if !defined(ETL_COMPILER_ARM5)
|
||||
#pragma pop_macro("min")
|
||||
#pragma pop_macro("max")
|
||||
|
||||
@ -33,7 +33,7 @@ SOFTWARE.
|
||||
* This file is intended to evaluated multiple times by design.
|
||||
*/
|
||||
|
||||
#if !defined(ETL_COMPILER_GREEN_HILLS) && !defined(ETL_COMPILER_IAR)
|
||||
#if !defined(ETL_COMPILER_GREEN_HILLS) && !defined(ETL_COMPILER_IAR) && !defined(ETL_COMPILER_TASKING)
|
||||
#if !defined(ETL_COMPILER_ARM5)
|
||||
#pragma push_macro("min")
|
||||
#pragma push_macro("max")
|
||||
|
||||
@ -954,22 +954,22 @@ namespace etl
|
||||
return get<typename variant_alternative<tIndex, TVariant>::type>(variant);
|
||||
}
|
||||
|
||||
#define ETL_GEN_LEGACY_VISIT(VISITQUAL, VARIANTQUAL) \
|
||||
template <typename TReturn, typename TVisitor, typename TVariant> \
|
||||
static TReturn visit(TVisitor VISITQUAL visitor, TVariant VARIANTQUAL variant) \
|
||||
{ \
|
||||
switch (variant.index()) \
|
||||
{ \
|
||||
case 0: return static_cast<TReturn>(visitor(get<0>(variant))); \
|
||||
case 1: return static_cast<TReturn>(visitor(get<1>(variant))); \
|
||||
case 2: return static_cast<TReturn>(visitor(get<2>(variant))); \
|
||||
case 3: return static_cast<TReturn>(visitor(get<3>(variant))); \
|
||||
case 4: return static_cast<TReturn>(visitor(get<4>(variant))); \
|
||||
case 5: return static_cast<TReturn>(visitor(get<5>(variant))); \
|
||||
case 6: return static_cast<TReturn>(visitor(get<6>(variant))); \
|
||||
case 7: return static_cast<TReturn>(visitor(get<7>(variant))); \
|
||||
default: ETL_ASSERT(false, ETL_ERROR(bad_variant_access)); \
|
||||
} \
|
||||
#define ETL_GEN_LEGACY_VISIT(VISITQUAL, VARIANTQUAL) \
|
||||
template <typename TReturn, typename TVisitor, typename TVariant> \
|
||||
static TReturn visit(TVisitor VISITQUAL visitor, TVariant VARIANTQUAL variant) \
|
||||
{ \
|
||||
switch (variant.index()) \
|
||||
{ \
|
||||
case 0: return static_cast<TReturn>(visitor(get<0>(variant))); \
|
||||
case 1: return static_cast<TReturn>(visitor(get<1>(variant))); \
|
||||
case 2: return static_cast<TReturn>(visitor(get<2>(variant))); \
|
||||
case 3: return static_cast<TReturn>(visitor(get<3>(variant))); \
|
||||
case 4: return static_cast<TReturn>(visitor(get<4>(variant))); \
|
||||
case 5: return static_cast<TReturn>(visitor(get<5>(variant))); \
|
||||
case 6: return static_cast<TReturn>(visitor(get<6>(variant))); \
|
||||
case 7: return static_cast<TReturn>(visitor(get<7>(variant))); \
|
||||
default: ETL_ASSERT_FAIL_AND_RETURN_VALUE(ETL_ERROR(bad_variant_access), TReturn()); \
|
||||
} \
|
||||
}
|
||||
|
||||
ETL_GEN_LEGACY_VISIT(&, &)
|
||||
|
||||
@ -227,7 +227,7 @@ namespace etl
|
||||
default:
|
||||
{
|
||||
// This should never occur.
|
||||
#if defined(ETL_IN_UNIT_TEST)
|
||||
#if defined(ETL_DEBUG)
|
||||
assert(false);
|
||||
#endif
|
||||
break;
|
||||
@ -701,6 +701,27 @@ namespace etl
|
||||
return *static_cast<T*>(data);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Emplace with variadic constructor parameters.
|
||||
//***************************************************************************
|
||||
template <size_t Index, typename... TArgs>
|
||||
etl::variant_alternative<Index, variant>& emplace(TArgs&&... args)
|
||||
{
|
||||
static_assert(Index < etl::private_variant::parameter_pack<TTypes...>::size, "Index of of range");
|
||||
|
||||
using type = etl::remove_cvref_t<T>;
|
||||
|
||||
operation(private_variant::Destroy, data, nullptr);
|
||||
|
||||
construct_in_place_args<type>(data, etl::forward<TArgs>(args)...);
|
||||
|
||||
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
|
||||
type_id = Index;
|
||||
|
||||
return etl::variant_alternative<Index, variant>(*static_cast<T*>(data));
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Move assignment operator for type.
|
||||
///\param value The value to assign.
|
||||
|
||||
@ -119,6 +119,13 @@ SOFTWARE.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_COMPILER_TYPE_DETECTED) && !defined(ETL_COMPILER_TASKING)
|
||||
#if defined(__TASKING__)
|
||||
#define ETL_COMPILER_TASKING
|
||||
#define ETL_COMPILER_TYPE_DETECTED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_COMPILER_TYPE_DETECTED)
|
||||
#define ETL_COMPILER_GENERIC
|
||||
#endif
|
||||
@ -187,6 +194,12 @@ SOFTWARE.
|
||||
#define ETL_USING_TEXAS_INSTRUMENTS_COMPILER 0
|
||||
#endif
|
||||
|
||||
#if defined(ETL_COMPILER_TASKING)
|
||||
#define ETL_USING_TASKING_COMPILER 1
|
||||
#else
|
||||
#define ETL_USING_TASKING_COMPILER 0
|
||||
#endif
|
||||
|
||||
#if defined(ETL_COMPILER_GENERIC)
|
||||
#define ETL_USING_GENERIC_COMPILER 1
|
||||
#else
|
||||
|
||||
@ -64,6 +64,9 @@ SOFTWARE.
|
||||
#elif defined(ETL_COMPILER_TEXAS_INSTRUMENTS)
|
||||
#define ETL_COMPILER_VERSION __TI_COMPILER_VERSION__
|
||||
#define ETL_COMPILER_FULL_VERSION __TI_COMPILER_VERSION__
|
||||
#elif defined(ETL_COMPILER_TASKING)
|
||||
#define ETL_COMPILER_VERSION __REVISION__
|
||||
#define ETL_COMPILER_FULL_VERSION __VERSION__
|
||||
#else
|
||||
#define ETL_COMPILER_VERSION 0
|
||||
#define ETL_COMPILER_FULL_VERSION 0
|
||||
|
||||
@ -36,6 +36,7 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "variant.h"
|
||||
#include "optional.h"
|
||||
|
||||
#if ETL_CPP11_NOT_SUPPORTED
|
||||
#if !defined(ETL_IN_UNIT_TEST)
|
||||
@ -53,6 +54,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef TValue value_type;
|
||||
typedef TError error_type;
|
||||
|
||||
//*******************************************
|
||||
/// Cannot be default constructed
|
||||
//*******************************************
|
||||
@ -181,7 +185,7 @@ namespace etl
|
||||
//*******************************************
|
||||
bool is_value() const
|
||||
{
|
||||
return (data.index() == 0U);
|
||||
return has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -189,7 +193,7 @@ namespace etl
|
||||
//*******************************************
|
||||
bool is_error() const
|
||||
{
|
||||
return (data.index() == 1U);
|
||||
return !has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -207,7 +211,7 @@ namespace etl
|
||||
//*******************************************
|
||||
TValue&& value()
|
||||
{
|
||||
return etl::move(etl::get<TValue>(etl::move(data)));
|
||||
return etl::move(etl::get<TValue>(data));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -226,7 +230,7 @@ namespace etl
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
TError&& error()
|
||||
{
|
||||
return etl::move(etl::get<TError>(etl::move(data)));
|
||||
return etl::move(etl::get<TError>(data));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -244,11 +248,13 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef void value_type;
|
||||
typedef TError error_type;
|
||||
|
||||
//*******************************************
|
||||
/// Default Constructor
|
||||
//*******************************************
|
||||
result()
|
||||
: err(TError())
|
||||
{
|
||||
}
|
||||
|
||||
@ -256,7 +262,7 @@ namespace etl
|
||||
/// Copy constructor
|
||||
//*******************************************
|
||||
result(const result& other)
|
||||
: err(other.err)
|
||||
: data(other.data)
|
||||
{
|
||||
}
|
||||
|
||||
@ -264,15 +270,15 @@ namespace etl
|
||||
/// Move constructor
|
||||
//*******************************************
|
||||
result(result&& other)
|
||||
: err(etl::move(other.err))
|
||||
: data(etl::move(other.data))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct from error
|
||||
//*******************************************
|
||||
result(const TError& err_)
|
||||
: err(err_)
|
||||
result(const TError& error)
|
||||
: data(error)
|
||||
{
|
||||
}
|
||||
|
||||
@ -280,8 +286,8 @@ namespace etl
|
||||
/// Move construct from error
|
||||
//*******************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
result(TError&& err_)
|
||||
: err(etl::move(err_))
|
||||
result(TError&& error)
|
||||
: data(etl::move(error))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
@ -289,9 +295,9 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Copy assign from error
|
||||
//*******************************************
|
||||
result& operator =(const TError& err_)
|
||||
result& operator =(const TError& error)
|
||||
{
|
||||
err = err_;
|
||||
data = error;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -301,17 +307,25 @@ namespace etl
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
result& operator =(TError&& err_)
|
||||
{
|
||||
err = etl::move(err_);
|
||||
data = etl::move(error);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// <b>true</b> if result contains a value
|
||||
//*******************************************
|
||||
bool has_value() const
|
||||
{
|
||||
return !data.has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// <b>true</b> if result contains a value
|
||||
//*******************************************
|
||||
bool is_value() const
|
||||
{
|
||||
return false;
|
||||
return has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -319,7 +333,7 @@ namespace etl
|
||||
//*******************************************
|
||||
bool is_error() const
|
||||
{
|
||||
return true;
|
||||
return !has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -328,7 +342,7 @@ namespace etl
|
||||
//*******************************************
|
||||
const TError& error() const
|
||||
{
|
||||
return err;
|
||||
return data.value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
@ -338,13 +352,126 @@ namespace etl
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
TError&& error()
|
||||
{
|
||||
return etl::move(err);
|
||||
return etl::move(data.value());
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
TError err;
|
||||
etl::optional<TError> data;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Result type.
|
||||
/// Specialisation for void error type.
|
||||
//*****************************************************************************
|
||||
template<typename TValue>
|
||||
class result<TValue, void>
|
||||
{
|
||||
public:
|
||||
|
||||
//*******************************************
|
||||
/// Default Constructor
|
||||
//*******************************************
|
||||
result()
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy constructor
|
||||
//*******************************************
|
||||
result(const result& other)
|
||||
: data(other.data)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move constructor
|
||||
//*******************************************
|
||||
result(result&& other)
|
||||
: data(etl::move(other.data))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Construct from error
|
||||
//*******************************************
|
||||
result(const TValue& value)
|
||||
: data(value)
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move construct from error
|
||||
//*******************************************
|
||||
result(TValue&& value)
|
||||
: data(etl::move(value))
|
||||
{
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Copy assign from error
|
||||
//*******************************************
|
||||
result& operator =(const TValue& value)
|
||||
{
|
||||
data = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Move assign from error
|
||||
//*******************************************
|
||||
result& operator =(TValue&& value)
|
||||
{
|
||||
data = etl::move(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// <b>true</b> if result contains a value
|
||||
//*******************************************
|
||||
bool has_value() const
|
||||
{
|
||||
return data.has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// <b>true</b> if result contains a value
|
||||
//*******************************************
|
||||
bool is_value() const
|
||||
{
|
||||
return has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// <b>true</b> if result contains an error
|
||||
//*******************************************
|
||||
bool is_error() const
|
||||
{
|
||||
return !has_value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns a const reference to the error.
|
||||
/// Undefined if the result does not contain an error.
|
||||
//*******************************************
|
||||
const TValue& value() const
|
||||
{
|
||||
return data.value();
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns an rvalue reference to the error.
|
||||
/// Undefined if the result does not contain an error.
|
||||
//*******************************************
|
||||
TValue&& value()
|
||||
{
|
||||
return etl::move(data.value());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
etl::optional<TValue> data;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ namespace etl
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR span(etl::array<U, N>& a, typename etl::enable_if<(N == Extent) && etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR span(etl::array<U, N>& a, typename etl::enable_if<(N == Extent) && etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: pbegin(a.data())
|
||||
{
|
||||
}
|
||||
@ -143,7 +143,7 @@ namespace etl
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR span(const etl::array<U, N>& a, typename etl::enable_if<(N == Extent) && etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR span(const etl::array<U, N>& a, typename etl::enable_if<(N == Extent) && etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: pbegin(a.data())
|
||||
{
|
||||
}
|
||||
@ -189,7 +189,7 @@ namespace etl
|
||||
template <typename TContainer>
|
||||
span(TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
|
||||
!etl::is_array<TContainer>::value &&
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: pbegin(a.data())
|
||||
{
|
||||
}
|
||||
@ -201,7 +201,7 @@ namespace etl
|
||||
template <typename TContainer>
|
||||
ETL_CONSTEXPR span(const TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
|
||||
!etl::is_array<TContainer>::value&&
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: pbegin(a.data())
|
||||
{
|
||||
}
|
||||
@ -510,7 +510,7 @@ namespace etl
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR span(etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR span(etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: pbegin(a.data())
|
||||
, pend(a.data() + a.size())
|
||||
{
|
||||
@ -520,7 +520,7 @@ namespace etl
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR span(const etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR span(const etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: pbegin(a.data())
|
||||
, pend(a.data() + a.size())
|
||||
{
|
||||
@ -570,7 +570,7 @@ namespace etl
|
||||
template <typename TContainer>
|
||||
ETL_CONSTEXPR span(TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
|
||||
!etl::is_array<TContainer>::value &&
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: pbegin(a.data())
|
||||
, pend(a.data() + a.size())
|
||||
{
|
||||
@ -583,7 +583,7 @@ namespace etl
|
||||
template <typename TContainer>
|
||||
ETL_CONSTEXPR span(const TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
|
||||
!etl::is_array<TContainer>::value &&
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type) ETL_NOEXCEPT
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: pbegin(a.data())
|
||||
, pend(a.data() + a.size())
|
||||
{
|
||||
|
||||
@ -702,7 +702,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// is_enum
|
||||
///\ingroup type_traits
|
||||
/// Implemented by checking if type is convertable to an integer thru static_cast
|
||||
/// Implemented by checking if type is convertible to an integer through static_cast
|
||||
|
||||
namespace private_type_traits
|
||||
{
|
||||
@ -1981,13 +1981,40 @@ namespace etl
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// is_constructible
|
||||
namespace private_type_traits
|
||||
{
|
||||
template <class, class T, class... Args>
|
||||
struct is_constructible_ : etl::false_type {};
|
||||
|
||||
template <class T, class... Args>
|
||||
struct is_constructible_<void_t<decltype(T(etl::declval<Args>()...))>, T, Args...> : etl::true_type {};
|
||||
};
|
||||
|
||||
|
||||
//*********************************************
|
||||
// is_constructible
|
||||
template <typename T, typename... TArgs>
|
||||
struct is_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
|
||||
{
|
||||
};
|
||||
#endif
|
||||
template <class T, class... Args>
|
||||
using is_constructible = private_type_traits::is_constructible_<void_t<>, T, Args...>;
|
||||
|
||||
//*********************************************
|
||||
// is_copy_constructible
|
||||
template <class T> struct is_copy_constructible : public is_constructible<T, typename etl::add_lvalue_reference<typename etl::add_const<T>::type>::type>{};
|
||||
template <> struct is_copy_constructible<void> : public false_type{};
|
||||
template <> struct is_copy_constructible<void const> : public false_type{};
|
||||
template <> struct is_copy_constructible<void volatile> : public false_type{};
|
||||
template <> struct is_copy_constructible<void const volatile> : public false_type{};
|
||||
|
||||
//*********************************************
|
||||
// is_move_constructible
|
||||
template <typename T> struct is_move_constructible: public is_constructible<T, typename etl::add_rvalue_reference<T>::type>{};
|
||||
template <> struct is_move_constructible<void> : public false_type{};
|
||||
template <> struct is_move_constructible<void const> : public false_type{};
|
||||
template <> struct is_move_constructible<void volatile> : public false_type{};
|
||||
template <> struct is_move_constructible<void const volatile> : public false_type{};
|
||||
|
||||
#else
|
||||
|
||||
//*********************************************
|
||||
// is_copy_constructible
|
||||
@ -2002,6 +2029,7 @@ namespace etl
|
||||
struct is_move_constructible : public etl::bool_constant<etl::is_arithmetic<T>::value || etl::is_pointer<T>::value>
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
//*********************************************
|
||||
// is_trivially_constructible
|
||||
|
||||
@ -459,7 +459,7 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename ... Args>
|
||||
void emplace_back(Args && ... args)
|
||||
reference emplace_back(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
@ -467,6 +467,7 @@ namespace etl
|
||||
::new (p_end) T(etl::forward<Args>(args)...);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
#else
|
||||
//*********************************************************************
|
||||
@ -475,7 +476,7 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1>
|
||||
void emplace_back(const T1& value1)
|
||||
reference emplace_back(const T1& value1)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
@ -483,6 +484,7 @@ namespace etl
|
||||
::new (p_end) T(value1);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -491,7 +493,7 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_back(const T1& value1, const T2& value2)
|
||||
reference emplace_back(const T1& value1, const T2& value2)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
@ -499,6 +501,7 @@ namespace etl
|
||||
::new (p_end) T(value1, value2);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -507,7 +510,7 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
@ -515,6 +518,7 @@ namespace etl
|
||||
::new (p_end) T(value1, value2, value3);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -523,7 +527,7 @@ namespace etl
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
@ -531,6 +535,7 @@ namespace etl
|
||||
::new (p_end) T(value1, value2, value3, value4);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return back();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1353,7 +1358,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
#if ETL_USING_CPP11 && ETL_HAS_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_vector(T... t) -> etl::vector<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
constexpr auto make_vector(T&&... t) -> etl::vector<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ SOFTWARE.
|
||||
|
||||
#define ETL_VERSION_MAJOR 20
|
||||
#define ETL_VERSION_MINOR 35
|
||||
#define ETL_VERSION_PATCH 0
|
||||
#define ETL_VERSION_PATCH 10
|
||||
|
||||
#define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "20.35.0",
|
||||
"version": "20.35.10",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=20.35.0
|
||||
version=20.35.10
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -12,10 +12,8 @@ project('etl',
|
||||
)
|
||||
|
||||
compile_args = []
|
||||
if get_option('use_stl')
|
||||
compile_args += '-DETL_NO_STL=0'
|
||||
elif
|
||||
compile_args += '-DETL_NO_STL=1'
|
||||
if not get_option('use_stl')
|
||||
compile_args += '-DETL_NO_STL'
|
||||
endif
|
||||
|
||||
etl_dep = declare_dependency(
|
||||
|
||||
@ -37,6 +37,9 @@ for generator in generator_folder.iterdir():
|
||||
print(f"Generator for {output_name} does not match file contents")
|
||||
all_ok = False
|
||||
|
||||
if not all_ok:
|
||||
if all_ok:
|
||||
print(f"\nAll generator tests passed\n")
|
||||
exit(0)
|
||||
else:
|
||||
print(f"\nGenerator tests failed\n")
|
||||
exit(1)
|
||||
exit(0)
|
||||
@ -1,3 +1,52 @@
|
||||
===============================================================================
|
||||
20.35.10
|
||||
#659 emplace member functions return reference to emplaced value
|
||||
|
||||
===============================================================================
|
||||
20.35.9
|
||||
#657 -Wpedantic-failure. Removed superfluous semicolons
|
||||
#653 CMake - Don't warn on tag missing when subproject
|
||||
#651 result<T, void> specialization
|
||||
#650 Fix result<void, E> default ctor
|
||||
Removed Ubuntu 18.04 from Github Actions
|
||||
Added Ubuntu 22.04 to Github Actions
|
||||
|
||||
===============================================================================
|
||||
20.35.8
|
||||
#648 Improve is_constructible, is_copy_constructible, is_move_constructible for type traits with default definitions
|
||||
#645 Avoid 'missing return statement at end of non-void function' in `etl::visit<>()`.
|
||||
Removed unused ETL_USE_MEM_BUILTINS option
|
||||
|
||||
===============================================================================
|
||||
20.35.7
|
||||
Updated etl::delgate to handle const functors correctly
|
||||
|
||||
===============================================================================
|
||||
20.35.6
|
||||
#643 Don't use push_macro and pull_macro with Tasking compiler
|
||||
|
||||
===============================================================================
|
||||
20.35.5
|
||||
#641 Wrong usage of enable_if for none C++11 compilers
|
||||
|
||||
===============================================================================
|
||||
20.35.4
|
||||
#639 Only build tests if top level project
|
||||
|
||||
===============================================================================
|
||||
20.35.3
|
||||
#636 Fix bug in optional emplace for pod type specialisation
|
||||
|
||||
===============================================================================
|
||||
20.35.2
|
||||
#634 Strange behavior in move assignment of optional
|
||||
|
||||
===============================================================================
|
||||
20.35.1
|
||||
#628 Fixed set of ETL_NO_STL flag in meson.build
|
||||
#631 unique_ptr derived copy or move to base does not compile
|
||||
Removed duplicate include in etl::array_view
|
||||
|
||||
===============================================================================
|
||||
20.35.0
|
||||
#596 Helper functions to convert strings to numeric values. etl::to_arithmetic
|
||||
|
||||
@ -102,6 +102,7 @@ add_executable(etl_tests
|
||||
test_error_handler.cpp
|
||||
test_etl_traits.cpp
|
||||
test_exception.cpp
|
||||
test_expected.cpp
|
||||
test_fixed_iterator.cpp
|
||||
test_fixed_sized_memory_block_allocator.cpp
|
||||
test_flags.cpp
|
||||
@ -284,11 +285,6 @@ if (ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
target_compile_definitions(etl_tests PRIVATE -DETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USE_MEM_BUILTINS)
|
||||
message(STATUS "Compiling for built-in memory functions")
|
||||
target_compile_definitions(etl_tests PRIVATE -DETL_USE_MEM_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USER_DEFINED_TYPE_TRAITS)
|
||||
message(STATUS "Compiling for user defined type traits")
|
||||
target_compile_definitions(etl_tests PRIVATE -DETL_USER_DEFINED_TYPE_TRAITS)
|
||||
@ -329,3 +325,4 @@ add_test(etl_unit_tests etl_tests)
|
||||
add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
|
||||
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17)
|
||||
|
||||
@ -97,7 +97,7 @@
|
||||
}) \
|
||||
UNITTEST_MULTILINE_MACRO_END
|
||||
|
||||
#define UNITTEST_CHECK_FALSE_EQUAL(expected, actual) \
|
||||
#define UNITTEST_CHECK_NOT_EQUAL(expected, actual) \
|
||||
UNITTEST_MULTILINE_MACRO_BEGIN \
|
||||
UNITTEST_IMPL_TRY \
|
||||
({ \
|
||||
@ -254,16 +254,16 @@
|
||||
#define CHECK_EQUAL_HEX UNITTEST_CHECK_EQUAL_HEX
|
||||
#endif
|
||||
|
||||
#ifdef CHECK_FALSE_EQUAL
|
||||
#error CHECK_FALSE_EQUAL already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_FALSE_EQUAL instead
|
||||
#ifdef CHECK_NOT_EQUAL
|
||||
#error CHECK_NOT_EQUAL already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_NOT_EQUAL instead
|
||||
#else
|
||||
#define CHECK_FALSE_EQUAL UNITTEST_CHECK_FALSE_EQUAL
|
||||
#define CHECK_NOT_EQUAL UNITTEST_CHECK_NOT_EQUAL
|
||||
#endif
|
||||
|
||||
#ifdef CHECK_FALSE_EQUAL_HEX
|
||||
#error CHECK_FALSE_EQUAL_HEX already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_FALSE_EQUAL_HEX instead
|
||||
#ifdef CHECK_NOT_EQUAL_HEX
|
||||
#error CHECK_NOT_EQUAL_HEX already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_NOT_EQUAL_HEX instead
|
||||
#else
|
||||
#define CHECK_FALSE_EQUAL_HEX UNITTEST_CHECK_FALSE_EQUAL_HEX
|
||||
#define CHECK_NOT_EQUAL_HEX UNITTEST_CHECK_NOT_EQUAL_HEX
|
||||
#endif
|
||||
|
||||
#ifdef CHECK_CLOSE
|
||||
|
||||
@ -19,7 +19,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -33,21 +33,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
{ echo ""; echo "GCC - No STL - Force Builtins"; } | tee -a ../log.txt
|
||||
rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -75,7 +61,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -89,21 +75,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
{ echo ""; echo "Clang - No STL - Force Builtins"; } | tee -a ../log.txt
|
||||
rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -138,7 +110,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -152,7 +124,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -166,21 +138,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
{ echo ""; echo "GCC - No STL - Force Builtins"; } | tee -a ../log.txt
|
||||
rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -208,7 +166,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -222,7 +180,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -236,21 +194,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
{ echo ""; echo "Clang - No STL - Force Builtins"; } | tee -a ../log.txt
|
||||
rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -285,7 +229,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -299,7 +243,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -313,21 +257,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
{ echo ""; echo "GCC - No STL - Force Builtins"; } | tee -a ../log.txt
|
||||
rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -355,7 +285,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -369,7 +299,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -383,21 +313,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
{ echo ""; echo "Clang - No STL - Force Builtins"; } | tee -a ../log.txt
|
||||
rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -432,7 +348,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -446,7 +362,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -460,7 +376,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -474,21 +390,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
{ echo ""; echo "GCC - No STL - Force Builtins"; } | tee -a ../log.txt
|
||||
rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
g++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=gcc CXX=g++ cmake -E chdir bgcc cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake --build bgcc
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -516,7 +418,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -530,7 +432,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
@ -544,21 +446,7 @@ rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
|
||||
{ echo ""; echo "Clang - No STL - Force Builtins"; } | tee -a ../log.txt
|
||||
rm -rdf bgcc
|
||||
rm -rdf bclang
|
||||
cmake -E make_directory bgcc bclang
|
||||
clang++ --version | head --lines=1 | tee -a ../log.txt
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
CC=clang CXX=clang++ cmake -E chdir bclang cmake -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake --build bclang
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Passed"
|
||||
|
||||
@ -15,7 +15,7 @@ echo " GCC - STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -36,7 +36,7 @@ echo " GCC - STL - Force C++03" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -57,28 +57,7 @@ echo " GCC - No STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " GCC - No STL - Force Builtins" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
gcc --version | grep gcc | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake -DCMAKE_CXX_COMPILER="g++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -103,7 +82,7 @@ echo " Clang - STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -124,7 +103,7 @@ echo " Clang - STL - Force C++03" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
@ -145,28 +124,7 @@ echo " Clang - No STL" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USE_MEM_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
./etl_tests
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Tests >>>>"
|
||||
else
|
||||
echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt
|
||||
exit $?
|
||||
fi
|
||||
echo ""
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
echo " Clang - No STL - Builtins" | tee -a log.txt
|
||||
echo "-----------------------------------------------" | tee -a log.txt
|
||||
rm * -rf
|
||||
clang --version | grep clang | tee -a log.txt
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USE_MEM_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
cmake -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF ..
|
||||
make -j4
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "<<<< Passed Compilation >>>>"
|
||||
|
||||
@ -17,11 +17,6 @@ if (ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USE_MEM_BUILTINS)
|
||||
message(STATUS "Compiling for built-in memory functions")
|
||||
add_definitions(-DETL_USE_MEM_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USER_DEFINED_TYPE_TRAITS)
|
||||
message(STATUS "Compiling for user defined type traits")
|
||||
add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS)
|
||||
@ -134,6 +129,7 @@ target_sources(t98 PRIVATE etl_profile.h
|
||||
../enum_type.h.t.cpp
|
||||
../error_handler.h.t.cpp
|
||||
../exception.h.t.cpp
|
||||
../expected.h.t.cpp
|
||||
../factorial.h.t.cpp
|
||||
../fibonacci.h.t.cpp
|
||||
../file_error_numbers.h.t.cpp
|
||||
|
||||
@ -17,11 +17,6 @@ if (ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USE_MEM_BUILTINS)
|
||||
message(STATUS "Compiling for built-in memory functions")
|
||||
add_definitions(-DETL_USE_MEM_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USER_DEFINED_TYPE_TRAITS)
|
||||
message(STATUS "Compiling for user defined type traits")
|
||||
add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS)
|
||||
@ -134,6 +129,7 @@ target_sources(t11 PRIVATE etl_profile.h
|
||||
../enum_type.h.t.cpp
|
||||
../error_handler.h.t.cpp
|
||||
../exception.h.t.cpp
|
||||
../expected.h.t.cpp
|
||||
../factorial.h.t.cpp
|
||||
../fibonacci.h.t.cpp
|
||||
../file_error_numbers.h.t.cpp
|
||||
|
||||
@ -17,11 +17,6 @@ if (ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USE_MEM_BUILTINS)
|
||||
message(STATUS "Compiling for built-in memory functions")
|
||||
add_definitions(-DETL_USE_MEM_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USER_DEFINED_TYPE_TRAITS)
|
||||
message(STATUS "Compiling for user defined type traits")
|
||||
add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS)
|
||||
@ -134,6 +129,7 @@ target_sources(t14 PRIVATE etl_profile.h
|
||||
../enum_type.h.t.cpp
|
||||
../error_handler.h.t.cpp
|
||||
../exception.h.t.cpp
|
||||
../expected.h.t.cpp
|
||||
../factorial.h.t.cpp
|
||||
../fibonacci.h.t.cpp
|
||||
../file_error_numbers.h.t.cpp
|
||||
|
||||
@ -17,11 +17,6 @@ if (ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USE_MEM_BUILTINS)
|
||||
message(STATUS "Compiling for built-in memory functions")
|
||||
add_definitions(-DETL_USE_MEM_BUILTINS)
|
||||
endif()
|
||||
|
||||
if (ETL_USER_DEFINED_TYPE_TRAITS)
|
||||
message(STATUS "Compiling for user defined type traits")
|
||||
add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS)
|
||||
@ -134,6 +129,7 @@ target_sources(t17 PRIVATE etl_profile.h
|
||||
../enum_type.h.t.cpp
|
||||
../error_handler.h.t.cpp
|
||||
../exception.h.t.cpp
|
||||
../expected.h.t.cpp
|
||||
../factorial.h.t.cpp
|
||||
../fibonacci.h.t.cpp
|
||||
../file_error_numbers.h.t.cpp
|
||||
|
||||
29
test/sanity-check/expected.h.t.cpp
Normal file
29
test/sanity-check/expected.h.t.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2023 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include <etl/expected.h>
|
||||
@ -37,10 +37,35 @@ SOFTWARE.
|
||||
|
||||
namespace
|
||||
{
|
||||
//*****************************************************************************
|
||||
enum class FunctionCalled : int
|
||||
{
|
||||
Not_Called,
|
||||
Free_Void_Called,
|
||||
Free_Int_Called,
|
||||
Free_Reference_Called,
|
||||
Free_Moveableonly_Called,
|
||||
Normal_Called,
|
||||
Normal_Returning_Void_Called,
|
||||
Alternative_Called,
|
||||
Member_Void_Called,
|
||||
Member_Void_Const_Called,
|
||||
Member_Int_Called,
|
||||
Member_Int_Const_Called,
|
||||
Member_Reference_Called,
|
||||
Member_Reference_Const_Called,
|
||||
Member_Moveableonly_Called,
|
||||
Member_Static_Called,
|
||||
Operator_Called,
|
||||
Operator_Const_Called,
|
||||
Lambda_Called
|
||||
};
|
||||
|
||||
FunctionCalled function_called = FunctionCalled::Not_Called;
|
||||
|
||||
//*****************************************************************************
|
||||
const int VALUE1 = 1;
|
||||
const int VALUE2 = 2;
|
||||
bool function_called = false;
|
||||
bool parameter_correct = false;
|
||||
|
||||
//*****************************************************************************
|
||||
@ -70,7 +95,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void free_void()
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Free_Void_Called;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
@ -78,7 +103,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void free_int(int i, int j)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Free_Int_Called;;
|
||||
parameter_correct = (i == VALUE1) && (j == VALUE2);
|
||||
}
|
||||
|
||||
@ -87,7 +112,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void free_reference(const Data& data, int j)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Free_Reference_Called;
|
||||
parameter_correct = (data.d == VALUE1) && (j == VALUE2);
|
||||
}
|
||||
|
||||
@ -96,7 +121,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void free_moveableonly(MoveableOnlyData&& data)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Free_Moveableonly_Called;
|
||||
parameter_correct = (data.d == VALUE1);
|
||||
}
|
||||
|
||||
@ -105,7 +130,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
int normal(int i, int j)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Normal_Called;
|
||||
parameter_correct = (i == VALUE1) && (j == VALUE2);
|
||||
|
||||
return i + j;
|
||||
@ -116,7 +141,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void normal_returning_void(int i, int j)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Normal_Returning_Void_Called;
|
||||
parameter_correct = (i == VALUE1) && (j == VALUE2);
|
||||
}
|
||||
|
||||
@ -125,7 +150,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
int alternative(int i, int j)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Alternative_Called;
|
||||
parameter_correct = (i == VALUE1) && (j == VALUE2);
|
||||
|
||||
return i + j + 1;
|
||||
@ -142,25 +167,25 @@ namespace
|
||||
// void
|
||||
void member_void()
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Void_Called;
|
||||
}
|
||||
|
||||
void member_void_const() const
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Void_Const_Called;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
// int
|
||||
void member_int(int i, int j)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Int_Called;
|
||||
parameter_correct = (i == VALUE1) && (j == VALUE2);
|
||||
}
|
||||
|
||||
void member_int_const(int i, int j) const
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Int_Const_Called;
|
||||
parameter_correct = (i == VALUE1) && (j == VALUE2);
|
||||
}
|
||||
|
||||
@ -168,13 +193,13 @@ namespace
|
||||
// reference
|
||||
void member_reference(const Data& data, int j)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Reference_Called;
|
||||
parameter_correct = (data.d == VALUE1) && (j == VALUE2);
|
||||
}
|
||||
|
||||
void member_reference_const(const Data& data, int j) const
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Reference_Const_Called;
|
||||
parameter_correct = (data.d == VALUE1) && (j == VALUE2);
|
||||
}
|
||||
|
||||
@ -182,7 +207,7 @@ namespace
|
||||
// moveable only data
|
||||
void member_moveableonly(MoveableOnlyData&& data)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Moveableonly_Called;
|
||||
parameter_correct = (data.d == VALUE1);
|
||||
}
|
||||
|
||||
@ -190,7 +215,7 @@ namespace
|
||||
// static
|
||||
static void member_static(const Data& data, int j)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Static_Called;
|
||||
parameter_correct = (data.d == VALUE1) && (j == VALUE2);
|
||||
}
|
||||
|
||||
@ -198,12 +223,12 @@ namespace
|
||||
// operator()
|
||||
void operator()()
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Operator_Called;
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Operator_Const_Called;
|
||||
}
|
||||
};
|
||||
|
||||
@ -226,7 +251,7 @@ namespace
|
||||
{
|
||||
SetupFixture()
|
||||
{
|
||||
function_called = false;
|
||||
function_called = FunctionCalled::Not_Called;
|
||||
parameter_correct = false;
|
||||
}
|
||||
};
|
||||
@ -272,7 +297,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -282,7 +307,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -292,7 +317,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -303,7 +328,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -317,7 +342,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -331,7 +356,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -345,7 +370,7 @@ namespace
|
||||
|
||||
d(std::move(data));
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Moveableonly_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -359,31 +384,31 @@ namespace
|
||||
|
||||
d(std::move(data));
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Moveableonly_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lambda_int)
|
||||
{
|
||||
etl::delegate<void(int, int)> d([](int i, int j) { function_called = true; parameter_correct = (i == VALUE1) && (j == VALUE2); });
|
||||
etl::delegate<void(int, int)> d([](int i, int j) { function_called = FunctionCalled::Lambda_Called; parameter_correct = (i == VALUE1) && (j == VALUE2); });
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Lambda_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_lambda_int_create)
|
||||
{
|
||||
auto lambda = [](int i, int j) { function_called = true; parameter_correct = (i == VALUE1) && (j == VALUE2); };
|
||||
auto lambda = [](int i, int j) { function_called = FunctionCalled::Lambda_Called; parameter_correct = (i == VALUE1) && (j == VALUE2); };
|
||||
|
||||
etl::delegate<void(int, int)> d(lambda);
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Lambda_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -396,7 +421,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -408,7 +433,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -420,7 +445,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -432,7 +457,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Const_Called);
|
||||
}
|
||||
|
||||
#if !defined(ETL_COMPILER_GCC)
|
||||
@ -443,7 +468,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -453,7 +478,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -463,7 +488,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Const_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -473,7 +498,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Const_Called);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -488,7 +513,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -500,7 +525,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -512,7 +537,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -524,7 +549,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Const_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -536,7 +561,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Const_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -548,7 +573,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -561,7 +586,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -574,7 +599,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -587,7 +612,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -602,7 +627,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -617,7 +642,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -632,7 +657,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -647,7 +672,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -662,7 +687,7 @@ namespace
|
||||
|
||||
d(std::move(data));
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Moveableonly_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -677,7 +702,7 @@ namespace
|
||||
|
||||
d(std::move(data));
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Moveableonly_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -691,7 +716,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Static_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -705,7 +730,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Static_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -717,7 +742,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -727,7 +752,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -737,7 +762,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Const_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -747,7 +772,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Const_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -757,7 +782,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -768,7 +793,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -779,7 +804,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -790,7 +815,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -804,7 +829,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -818,7 +843,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -832,7 +857,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -846,7 +871,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -859,7 +884,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -868,11 +893,11 @@ namespace
|
||||
{
|
||||
etl::delegate<void(int, int)> d;
|
||||
|
||||
d.set([](int i, int j) { function_called = true; parameter_correct = (i == VALUE1) && (j == VALUE2); });
|
||||
d.set([](int i, int j) { function_called = FunctionCalled::Lambda_Called; parameter_correct = (i == VALUE1) && (j == VALUE2); });
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Lambda_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -889,7 +914,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -906,7 +931,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -922,7 +947,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -938,7 +963,7 @@ namespace
|
||||
|
||||
d(data, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
#endif
|
||||
@ -953,7 +978,7 @@ namespace
|
||||
|
||||
d2(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -967,7 +992,7 @@ namespace
|
||||
|
||||
d2(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -983,7 +1008,7 @@ namespace
|
||||
|
||||
d2(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -1090,7 +1115,7 @@ namespace
|
||||
bool was_called = d.call_if(VALUE1, VALUE2);
|
||||
|
||||
CHECK(was_called);
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Normal_Returning_Void_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -1102,7 +1127,7 @@ namespace
|
||||
bool was_called = d.call_if(VALUE1, VALUE2);
|
||||
|
||||
CHECK(!was_called);
|
||||
CHECK(!function_called);
|
||||
CHECK(function_called == FunctionCalled::Not_Called);
|
||||
CHECK(!parameter_correct);
|
||||
}
|
||||
|
||||
@ -1115,7 +1140,7 @@ namespace
|
||||
|
||||
d(VALUE1, VALUE2);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
};
|
||||
|
||||
@ -35,9 +35,34 @@ SOFTWARE.
|
||||
|
||||
namespace
|
||||
{
|
||||
//*****************************************************************************
|
||||
enum class FunctionCalled : int
|
||||
{
|
||||
Not_Called,
|
||||
Free_Void_Called,
|
||||
Free_Int_Called,
|
||||
Free_Reference_Called,
|
||||
Free_Moveableonly_Called,
|
||||
Normal_Called,
|
||||
Normal_Returning_Void_Called,
|
||||
Alternative_Called,
|
||||
Member_Void_Called,
|
||||
Member_Void_Const_Called,
|
||||
Member_Int_Called,
|
||||
Member_Int_Const_Called,
|
||||
Member_Reference_Called,
|
||||
Member_Reference_Const_Called,
|
||||
Member_Moveableonly_Called,
|
||||
Member_Static_Called,
|
||||
Operator_Called,
|
||||
Operator_Const_Called,
|
||||
Lambda_Called
|
||||
};
|
||||
|
||||
FunctionCalled function_called = FunctionCalled::Not_Called;
|
||||
|
||||
//*****************************************************************************
|
||||
const int VALUE1 = 1;
|
||||
bool function_called = false;
|
||||
bool parameter_correct = false;
|
||||
|
||||
//*****************************************************************************
|
||||
@ -53,7 +78,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void free_void()
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Free_Void_Called;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
@ -61,7 +86,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void free_int(int i)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Free_Int_Called;
|
||||
parameter_correct = (i == VALUE1);
|
||||
}
|
||||
|
||||
@ -70,7 +95,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void free_reference(const Data& data)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Free_Reference_Called;
|
||||
parameter_correct = (data.d == VALUE1);
|
||||
}
|
||||
|
||||
@ -79,7 +104,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
int normal(int i)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Normal_Called;
|
||||
parameter_correct = (i == VALUE1);
|
||||
|
||||
return i;
|
||||
@ -90,7 +115,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
void normal_returning_void(int i)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Normal_Returning_Void_Called;
|
||||
parameter_correct = (i == VALUE1);
|
||||
}
|
||||
|
||||
@ -99,7 +124,7 @@ namespace
|
||||
//*****************************************************************************
|
||||
int alternative(int i)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Alternative_Called;
|
||||
parameter_correct = (i == VALUE1);
|
||||
|
||||
return i + 1;
|
||||
@ -116,25 +141,25 @@ namespace
|
||||
// void
|
||||
void member_void()
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Void_Called;
|
||||
}
|
||||
|
||||
void member_void_const() const
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Void_Const_Called;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
// int
|
||||
void member_int(int i)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Int_Called;
|
||||
parameter_correct = (i == VALUE1);
|
||||
}
|
||||
|
||||
void member_int_const(int i) const
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Int_Const_Called;
|
||||
parameter_correct = (i == VALUE1);
|
||||
}
|
||||
|
||||
@ -142,13 +167,13 @@ namespace
|
||||
// reference
|
||||
void member_reference(const Data& data)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Reference_Called;
|
||||
parameter_correct = (data.d == VALUE1);
|
||||
}
|
||||
|
||||
void member_reference_const(const Data& data) const
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Reference_Const_Called;
|
||||
parameter_correct = (data.d == VALUE1);
|
||||
}
|
||||
|
||||
@ -156,7 +181,7 @@ namespace
|
||||
// static
|
||||
static void member_static(const Data& data)
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Member_Static_Called;
|
||||
parameter_correct = (data.d == VALUE1);
|
||||
}
|
||||
|
||||
@ -164,12 +189,12 @@ namespace
|
||||
// operator()
|
||||
void operator()()
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Operator_Called;
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
function_called = true;
|
||||
function_called = FunctionCalled::Operator_Const_Called;
|
||||
}
|
||||
};
|
||||
|
||||
@ -192,7 +217,7 @@ namespace
|
||||
{
|
||||
SetupFixture()
|
||||
{
|
||||
function_called = false;
|
||||
function_called = FunctionCalled::Not_Called;
|
||||
parameter_correct = false;
|
||||
}
|
||||
};
|
||||
@ -217,7 +242,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -227,7 +252,7 @@ namespace
|
||||
|
||||
d(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -241,7 +266,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -254,7 +279,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -266,7 +291,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -278,7 +303,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Const_Called);
|
||||
}
|
||||
|
||||
#if !defined(ETL_COMPILER_GCC)
|
||||
@ -289,7 +314,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -299,7 +324,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Const_Called);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -314,7 +339,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Operator_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -326,7 +351,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -338,7 +363,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Const_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -350,7 +375,7 @@ namespace
|
||||
|
||||
d(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -363,7 +388,7 @@ namespace
|
||||
|
||||
d(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -378,7 +403,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -393,7 +418,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -407,7 +432,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Static_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -419,7 +444,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -429,7 +454,7 @@ namespace
|
||||
|
||||
d();
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Void_Const_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -439,7 +464,7 @@ namespace
|
||||
|
||||
d(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -450,7 +475,7 @@ namespace
|
||||
|
||||
d(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -464,7 +489,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -478,7 +503,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -491,7 +516,7 @@ namespace
|
||||
|
||||
d(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Free_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -500,11 +525,11 @@ namespace
|
||||
{
|
||||
etl_cpp03::delegate<void(int)> d;
|
||||
|
||||
d.set([](int i) { function_called = true; parameter_correct = (i == VALUE1); });
|
||||
d.set([](int i) { function_called = FunctionCalled::Lambda_Called; parameter_correct = (i == VALUE1); });
|
||||
|
||||
d(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Lambda_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -521,7 +546,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -538,7 +563,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -554,7 +579,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -570,7 +595,7 @@ namespace
|
||||
|
||||
d(data);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Reference_Const_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
#endif
|
||||
@ -585,7 +610,7 @@ namespace
|
||||
|
||||
d2(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -601,7 +626,7 @@ namespace
|
||||
|
||||
d2(VALUE1);
|
||||
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Member_Int_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -708,7 +733,7 @@ namespace
|
||||
bool was_called = d.call_if(VALUE1);
|
||||
|
||||
CHECK(was_called);
|
||||
CHECK(function_called);
|
||||
CHECK(function_called == FunctionCalled::Normal_Returning_Void_Called);
|
||||
CHECK(parameter_correct);
|
||||
}
|
||||
|
||||
@ -720,7 +745,7 @@ namespace
|
||||
bool was_called = d.call_if(VALUE1);
|
||||
|
||||
CHECK(!was_called);
|
||||
CHECK(!function_called);
|
||||
CHECK(function_called == FunctionCalled::Not_Called);
|
||||
CHECK(!parameter_correct);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1490,6 +1490,16 @@ namespace
|
||||
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_emplace_back_return)
|
||||
{
|
||||
DataNDC data;
|
||||
|
||||
data.emplace_back("24");
|
||||
auto& back = data.emplace_back("42");
|
||||
CHECK_EQUAL(back, data.back());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_push_back_excess)
|
||||
{
|
||||
@ -1602,6 +1612,16 @@ namespace
|
||||
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_emplace_front_return)
|
||||
{
|
||||
DataNDC data;
|
||||
|
||||
data.emplace_front("24");
|
||||
auto& front = data.emplace_front("42");
|
||||
CHECK_EQUAL(front, data.front());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_push_front_excess)
|
||||
{
|
||||
|
||||
446
test/test_expected.cpp
Normal file
446
test/test_expected.cpp
Normal file
@ -0,0 +1,446 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2022 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "unit_test_framework.h"
|
||||
|
||||
#include "etl/expected.h"
|
||||
#include "etl/type_traits.h"
|
||||
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Value
|
||||
{
|
||||
std::string v;
|
||||
|
||||
Value()
|
||||
{
|
||||
}
|
||||
|
||||
Value(const std::string v_)
|
||||
: v(v_)
|
||||
{
|
||||
}
|
||||
|
||||
operator std::string() const
|
||||
{
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
struct ValueM
|
||||
{
|
||||
ValueM()
|
||||
{
|
||||
}
|
||||
|
||||
ValueM(const std::string& v_)
|
||||
: v(v_)
|
||||
{
|
||||
}
|
||||
|
||||
ValueM(ValueM&&) = default;
|
||||
ValueM& operator =(ValueM&&) = default;
|
||||
|
||||
ValueM(const ValueM&) = delete;
|
||||
ValueM& operator =(const ValueM&) = delete;
|
||||
|
||||
std::string v;
|
||||
};
|
||||
|
||||
struct Error
|
||||
{
|
||||
std::string e;
|
||||
|
||||
Error() = default;
|
||||
Error(const Error&) = default;
|
||||
Error& operator =(const Error&) = default;
|
||||
|
||||
Error(const std::string e_)
|
||||
: e(e_)
|
||||
{
|
||||
}
|
||||
|
||||
Error& operator =(const std::string e_)
|
||||
{
|
||||
e = e_;
|
||||
}
|
||||
|
||||
operator std::string() const
|
||||
{
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
struct ErrorM
|
||||
{
|
||||
ErrorM()
|
||||
{
|
||||
}
|
||||
|
||||
ErrorM(const std::string& e_)
|
||||
: e(e_)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorM(ErrorM&&) = default;
|
||||
ErrorM& operator =(ErrorM&&) = default;
|
||||
|
||||
ErrorM(const ErrorM&) = delete;
|
||||
ErrorM& operator =(const ErrorM&) = delete;
|
||||
|
||||
std::string e;
|
||||
};
|
||||
|
||||
using Expected = etl::expected<Value, Error>;
|
||||
using ExpectedV = etl::expected<void, Error>;
|
||||
using ExpectedM = etl::expected<ValueM, ErrorM>;
|
||||
using ExpectedVM = etl::expected<void, ErrorM>;
|
||||
|
||||
using Unexpected = etl::unexpected<Error>;
|
||||
using UnexpectedV = etl::unexpected<Error>;
|
||||
using UnexpectedM = etl::unexpected<ErrorM>;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_result)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_default_constructor)
|
||||
{
|
||||
Expected expected;
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
Expected expected(input);
|
||||
|
||||
Value output = expected.value();
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
CHECK_TRUE(output.v == input.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
const Expected expected(input);
|
||||
|
||||
const Value& output = expected.value();
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
CHECK_TRUE(output.v == input.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_with_value)
|
||||
{
|
||||
ValueM input = { "value 1" };
|
||||
ExpectedM expected(etl::move(input));
|
||||
|
||||
ValueM output = etl::move(expected.value());
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
CHECK_TRUE(output.v == std::string("value 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
Unexpected unexpected(input);
|
||||
Expected expected(unexpected);
|
||||
|
||||
Error output = expected.error();
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK(output.e == input.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_with_error)
|
||||
{
|
||||
const Error input = { "error 1" };
|
||||
const Unexpected unexpected(input);
|
||||
const Expected expected(unexpected);
|
||||
|
||||
const Error& output = expected.error();
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK(output.e == input.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_with_error)
|
||||
{
|
||||
ErrorM input = { "error 1" };
|
||||
UnexpectedM unexpected(etl::move(input));
|
||||
ExpectedM expected(etl::move(unexpected));
|
||||
|
||||
ErrorM output = etl::move(expected.error());
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK_TRUE(output.e == std::string("error 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_void_value_with_value)
|
||||
{
|
||||
ExpectedV expected;
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_void_value_with_value)
|
||||
{
|
||||
const ExpectedV expected;
|
||||
|
||||
CHECK_TRUE(expected.has_value());
|
||||
CHECK_TRUE(bool(expected));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_void_value_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
UnexpectedV unexpected(input);
|
||||
ExpectedV expected(unexpected);
|
||||
|
||||
Error output = expected.error();
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK_TRUE(output.e == input.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_void_value_with_error)
|
||||
{
|
||||
const Error input = { "error 1" };
|
||||
const UnexpectedV unexpected(input);
|
||||
const ExpectedV expected(unexpected);
|
||||
|
||||
const Error& output = expected.error();
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK_TRUE(output.e == input.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_void_value_with_error)
|
||||
{
|
||||
ErrorM input = { "error 1" };
|
||||
UnexpectedM unexpected(etl::move(input));
|
||||
ExpectedM expected(etl::move(unexpected));
|
||||
|
||||
ErrorM output = etl::move(expected.error());
|
||||
|
||||
CHECK_FALSE(expected.has_value());
|
||||
CHECK_FALSE(bool(expected));
|
||||
CHECK(output.e == std::string("error 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_construct)
|
||||
{
|
||||
Value input1 = { "value 1" };
|
||||
Expected expected1(input1);
|
||||
Expected expected2(expected1);
|
||||
|
||||
Value output1 = expected2.value();
|
||||
|
||||
CHECK_TRUE(expected1.has_value());
|
||||
CHECK_TRUE(expected2.has_value());
|
||||
CHECK(output1.v == input1.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_assign)
|
||||
{
|
||||
Value input1 = { "value 1" };
|
||||
Expected expected1(input1);
|
||||
|
||||
Value input2 = { "value 2" };
|
||||
Expected expected2(input2);
|
||||
|
||||
expected2 = expected1;
|
||||
|
||||
Value output1 = expected1.value();
|
||||
Value output2 = expected2.value();
|
||||
|
||||
CHECK_TRUE(expected1.has_value());
|
||||
CHECK_TRUE(expected2.has_value());
|
||||
|
||||
//CHECK(output1.v != input1.v);
|
||||
//CHECK(output2.v != input1.v);
|
||||
|
||||
//CHECK(output1.v == input2.v);
|
||||
//CHECK(output2.v == input2.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_construct)
|
||||
{
|
||||
ValueM input1 = { "value 1" };
|
||||
ExpectedM expected1(etl::move(input1));
|
||||
ExpectedM expected2(etl::move(expected1));
|
||||
|
||||
ValueM output1 = etl::move(expected1.value());
|
||||
ValueM output2 = etl::move(expected2.value());
|
||||
|
||||
CHECK_TRUE(expected1.has_value());
|
||||
CHECK_TRUE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL("", output1.v);
|
||||
CHECK_EQUAL("value 1", output2.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_assign)
|
||||
{
|
||||
ValueM input1 = { "value 1" };
|
||||
ExpectedM expected1(etl::move(input1));
|
||||
|
||||
ValueM input2 = { "value 2" };
|
||||
ExpectedM expected2(etl::move(input2));
|
||||
|
||||
expected2 = etl::move(expected1);
|
||||
|
||||
ValueM output1 = etl::move(expected1.value());
|
||||
ValueM output2 = etl::move(expected2.value());
|
||||
|
||||
CHECK_TRUE(expected1.has_value());
|
||||
CHECK_TRUE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL("", output1.v);
|
||||
CHECK_EQUAL("value 1", output2.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_construct_void_value)
|
||||
{
|
||||
Error input1 = { "error 1" };
|
||||
UnexpectedV unexpected1(input1);
|
||||
ExpectedV expected1(unexpected1);
|
||||
ExpectedV expected2(expected1);
|
||||
|
||||
CHECK_FALSE(expected1.has_value());
|
||||
CHECK_FALSE(expected2.has_value());
|
||||
|
||||
Error output1 = expected1.error();
|
||||
Error output2 = expected2.error();
|
||||
|
||||
CHECK_EQUAL(input1.e, output1.e);
|
||||
CHECK_EQUAL(input1.e, output2.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_assign_void_value)
|
||||
{
|
||||
Error input1 = { "error 1" };
|
||||
UnexpectedV unexpected1(input1);
|
||||
|
||||
Error input2 = { "error 2" };
|
||||
UnexpectedV unexpected2(input2);
|
||||
|
||||
ExpectedV expected1(unexpected1);
|
||||
ExpectedV expected2(unexpected2);
|
||||
|
||||
expected2 = expected1;
|
||||
|
||||
Error output1 = expected1.error();
|
||||
Error output2 = expected2.error();
|
||||
|
||||
CHECK_FALSE(expected1.has_value());
|
||||
CHECK_FALSE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL(input1.e, output1.e);
|
||||
CHECK_EQUAL(input1.e, output2.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_construct_void_value)
|
||||
{
|
||||
ErrorM input1 = { "error 1" };
|
||||
UnexpectedM unexpected1(etl::move(input1));
|
||||
ExpectedVM expected1(etl::move(unexpected1));
|
||||
ExpectedVM expected2(etl::move(expected1));
|
||||
|
||||
ErrorM output1 = etl::move(expected1.error());
|
||||
ErrorM output2 = etl::move(expected2.error());
|
||||
|
||||
CHECK_FALSE(expected1.has_value());
|
||||
CHECK_FALSE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL("", output1.e);
|
||||
CHECK_EQUAL("error 1", output2.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_assign_void_value)
|
||||
{
|
||||
ErrorM input1 = { "error 1" };
|
||||
UnexpectedM unexpected1(etl::move(input1));
|
||||
|
||||
ErrorM input2 = { "error 2" };
|
||||
UnexpectedM unexpected2(etl::move(input2));
|
||||
|
||||
ExpectedVM expected1(etl::move(unexpected1));
|
||||
ExpectedVM expected2(etl::move(unexpected2));
|
||||
|
||||
expected2 = etl::move(expected1);
|
||||
|
||||
ErrorM output1 = etl::move(expected1.error());
|
||||
ErrorM output2 = etl::move(expected2.error());
|
||||
|
||||
CHECK_FALSE(expected1.has_value());
|
||||
CHECK_FALSE(expected2.has_value());
|
||||
|
||||
CHECK_EQUAL("", output1.e);
|
||||
CHECK_EQUAL("error 1", output2.e);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -694,6 +694,16 @@ namespace
|
||||
CHECK(are_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_front_return)
|
||||
{
|
||||
DataNDC data;
|
||||
|
||||
data.emplace_front("24");
|
||||
auto& front = data.emplace_front("42");
|
||||
CHECK_EQUAL(front, data.front());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_after)
|
||||
{
|
||||
|
||||
@ -715,6 +715,18 @@ namespace
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
|
||||
{
|
||||
DataNDC data;
|
||||
std::string value1("A");
|
||||
std::string value2("B");
|
||||
|
||||
data.emplace_back(value1);
|
||||
auto& back = data.emplace_back(value2);
|
||||
CHECK_EQUAL(back, data.back());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_push_back_unique_ptr)
|
||||
{
|
||||
|
||||
@ -731,6 +731,16 @@ namespace
|
||||
CHECK(are_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_front_return)
|
||||
{
|
||||
DataNDC data;
|
||||
|
||||
data.emplace_front("24");
|
||||
auto& front = data.emplace_front("42");
|
||||
CHECK_EQUAL(front, data.front());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_push_front_excess)
|
||||
{
|
||||
@ -887,6 +897,16 @@ namespace
|
||||
CHECK(are_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
|
||||
{
|
||||
DataNDC data;
|
||||
|
||||
data.emplace_back("24");
|
||||
auto& back = data.emplace_back("42");
|
||||
CHECK_EQUAL(back, data.back());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_push_back_excess)
|
||||
{
|
||||
|
||||
@ -41,6 +41,8 @@ SOFTWARE.
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -1301,5 +1303,46 @@ namespace
|
||||
CHECK((reinterpret_cast<const char*>(data) + 18) == p1);
|
||||
CHECK((reinterpret_cast<const char*>(data) + 32) == p2);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
class Base
|
||||
{
|
||||
public:
|
||||
virtual ~Base() {};
|
||||
virtual void function() = 0;
|
||||
};
|
||||
|
||||
static bool function_was_called = false;
|
||||
|
||||
class Derived : public Base
|
||||
{
|
||||
public:
|
||||
Derived()
|
||||
{
|
||||
function_was_called = false;
|
||||
}
|
||||
|
||||
void function()
|
||||
{
|
||||
function_was_called = true;
|
||||
}
|
||||
};
|
||||
|
||||
void call(etl::unique_ptr<Base> ptr)
|
||||
{
|
||||
ptr->function();
|
||||
}
|
||||
|
||||
TEST(test_derived_type)
|
||||
{
|
||||
CHECK(!function_was_called);
|
||||
|
||||
etl::unique_ptr<Derived> ptr(new Derived());
|
||||
CHECK(ptr.get() != ETL_NULLPTR);
|
||||
|
||||
call(etl::move(ptr));
|
||||
CHECK(function_was_called);
|
||||
CHECK(ptr.get() == ETL_NULLPTR);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -127,6 +127,13 @@ namespace
|
||||
CHECK_EQUAL(1, DataM::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_emplace_return)
|
||||
{
|
||||
etl::optional<DataM> data;
|
||||
CHECK_EQUAL(42U, data.emplace(42U).value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_moveable)
|
||||
{
|
||||
@ -466,5 +473,33 @@ namespace
|
||||
data.reset();
|
||||
CHECK(!bool(data));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
etl::optional<std::uint8_t> get_optional_test_bug_634()
|
||||
{
|
||||
etl::optional<std::uint8_t> result = 8;
|
||||
result.reset();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST(test_bug_634)
|
||||
{
|
||||
etl::optional<std::uint8_t> result;
|
||||
|
||||
result = get_optional_test_bug_634();
|
||||
|
||||
CHECK_EQUAL(false, result.has_value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_optional_emplace_bug_636)
|
||||
{
|
||||
etl::optional<std::uint8_t> result = 1;
|
||||
result.emplace(2);
|
||||
|
||||
CHECK_TRUE(result.has_value());
|
||||
CHECK_EQUAL(2, result.value());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2017 John Wellbelove
|
||||
Copyright(c) 2022 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -85,69 +85,21 @@ namespace
|
||||
std::string e;
|
||||
};
|
||||
|
||||
using Result = etl::result<Value, Error>;
|
||||
using ResultV = etl::result<void, Error>;
|
||||
using ResultM = etl::result<ValueM, ErrorM>;
|
||||
using ResultValueError = etl::result<Value, Error>;
|
||||
using ResultVoidError = etl::result<void, Error>;
|
||||
using ResultValueVoid = etl::result<Value, void>;
|
||||
using ResultM = etl::result<ValueM, ErrorM>;
|
||||
}
|
||||
|
||||
// Definitions for when the STL and compiler built-ins are not available.
|
||||
#if ETL_NOT_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS)
|
||||
|
||||
using etl::is_copy_constructible;
|
||||
using etl::is_move_constructible;
|
||||
|
||||
//*************************
|
||||
template <>
|
||||
struct etl::is_copy_constructible<Value> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_move_constructible<Value> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_copy_constructible<Error> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_move_constructible<Error> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
//*************************
|
||||
template <>
|
||||
struct etl::is_copy_constructible<ValueM> : public etl::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_move_constructible<ValueM> : public etl::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_copy_constructible<ErrorM> : public etl::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_move_constructible<ErrorM> : public etl::false_type
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_result)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_with_value)
|
||||
TEST(test_construct_result_value_error_type_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
Result result(input);
|
||||
ResultValueError result(input);
|
||||
|
||||
Value output = result.value();
|
||||
|
||||
@ -157,10 +109,10 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_with_value)
|
||||
TEST(test_construct_const_result_value_error_type_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
const Result result(input);
|
||||
const ResultValueError result(input);
|
||||
|
||||
const Value& output = result.value();
|
||||
|
||||
@ -170,7 +122,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_with_value)
|
||||
TEST(test_construct_moveable_result_value_error_type_with_value)
|
||||
{
|
||||
ValueM input = { "value 1" };
|
||||
ResultM result(etl::move(input));
|
||||
@ -183,10 +135,10 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_with_error)
|
||||
TEST(test_construct_result_value_error_type_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
Result result(input);
|
||||
ResultValueError result(input);
|
||||
|
||||
Error output = result.error();
|
||||
|
||||
@ -196,10 +148,10 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_with_error)
|
||||
TEST(test_construct_const_result_value_error_type_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
const Result result(input);
|
||||
const ResultValueError result(input);
|
||||
|
||||
const Error& output = result.error();
|
||||
|
||||
@ -209,7 +161,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_with_error)
|
||||
TEST(test_construct_moveable_result_value_error_type_with_error)
|
||||
{
|
||||
ErrorM input = { "error 1" };
|
||||
ResultM result(etl::move(input));
|
||||
@ -222,28 +174,28 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_void_value_with_value)
|
||||
TEST(test_default_construct_result_void_error_type)
|
||||
{
|
||||
ResultV result;
|
||||
ResultVoidError result;
|
||||
|
||||
CHECK(!result.is_value());
|
||||
CHECK(result.is_error());
|
||||
CHECK(result.is_value());
|
||||
CHECK(!result.is_error());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_void_value_with_value)
|
||||
TEST(test_default_construct_const_result_void_error_type)
|
||||
{
|
||||
const ResultV result;
|
||||
const ResultVoidError result;
|
||||
|
||||
CHECK(!result.is_value());
|
||||
CHECK(result.is_error());
|
||||
CHECK(result.is_value());
|
||||
CHECK(!result.is_error());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_result_void_value_with_error)
|
||||
TEST(test_construct_result_void_error_type_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
ResultV result(input);
|
||||
ResultVoidError result(input);
|
||||
|
||||
Error output = result.error();
|
||||
|
||||
@ -253,10 +205,10 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_const_result_void_value_with_error)
|
||||
TEST(test_construct_const_result_void_error_type_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
const ResultV result(input);
|
||||
const ResultVoidError result(input);
|
||||
|
||||
const Error& output = result.error();
|
||||
|
||||
@ -266,10 +218,10 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_result_void_value_with_error)
|
||||
TEST(test_construct_moveable_result_void_error_type_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
ResultV result(etl::move(input));
|
||||
ResultVoidError result(etl::move(input));
|
||||
|
||||
Error output = etl::move(result.error());
|
||||
|
||||
@ -279,10 +231,10 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_for_moveable_const_result_void_value_with_error)
|
||||
TEST(test_construct_moveable_const_result_void_error_type_with_error)
|
||||
{
|
||||
Error input = { "error 1" };
|
||||
const ResultV result(etl::move(input));
|
||||
const ResultVoidError result(etl::move(input));
|
||||
|
||||
Error output = etl::move(result.error());
|
||||
|
||||
@ -291,13 +243,83 @@ namespace
|
||||
CHECK(output.e == std::string("error 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_default_construct_result_value_void_type)
|
||||
{
|
||||
ResultValueVoid result;
|
||||
|
||||
CHECK(!result.is_value());
|
||||
CHECK(result.is_error());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_default_construct_const_result_value_void_type)
|
||||
{
|
||||
const ResultValueVoid result;
|
||||
|
||||
CHECK(!result.is_value());
|
||||
CHECK(result.is_error());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_construct_result_value_void_type_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
ResultValueVoid result(input);
|
||||
|
||||
Value output = result.value();
|
||||
|
||||
CHECK(result.is_value());
|
||||
CHECK(!result.is_error());
|
||||
CHECK(output.v == input.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_construct_const_result_value_void_type_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
const ResultValueVoid result(input);
|
||||
|
||||
const Value output = result.value();
|
||||
|
||||
CHECK(result.is_value());
|
||||
CHECK(!result.is_error());
|
||||
CHECK(output.v == input.v);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_construct_moveable_result_value_void_type_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
ResultValueVoid result(etl::move(input));
|
||||
|
||||
Value output = etl::move(result.value());
|
||||
|
||||
CHECK(result.is_value());
|
||||
CHECK(!result.is_error());
|
||||
CHECK(output.v == std::string("value 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_construct_moveable_const_result_value_void_type_with_value)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
const ResultValueVoid result(etl::move(input));
|
||||
|
||||
Value output = etl::move(result.value());
|
||||
|
||||
CHECK(result.is_value());
|
||||
CHECK(!result.is_error());
|
||||
CHECK(output.v == std::string("value 1"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_construct_result)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
Result result(input);
|
||||
ResultValueError result(input);
|
||||
|
||||
Result result2(result);
|
||||
ResultValueError result2(result);
|
||||
|
||||
Value output = result2.value();
|
||||
|
||||
@ -312,9 +334,9 @@ namespace
|
||||
TEST(test_move_construct_result)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
Result result(input);
|
||||
ResultValueError result(input);
|
||||
|
||||
Result result2(etl::move(result));
|
||||
ResultValueError result2(etl::move(result));
|
||||
|
||||
Value output = result.value();
|
||||
Value output2 = result2.value();
|
||||
@ -331,10 +353,10 @@ namespace
|
||||
TEST(test_move_assign_result)
|
||||
{
|
||||
Value input = { "value 1" };
|
||||
Result result(input);
|
||||
ResultValueError result(input);
|
||||
|
||||
Value input2 = { "value 2" };
|
||||
Result result2(result);
|
||||
ResultValueError result2(result);
|
||||
|
||||
result2 = etl::move(result);
|
||||
|
||||
|
||||
@ -127,11 +127,6 @@ struct etl::is_assignable<Copyable, Copyable> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_constructible<Copyable> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_copy_constructible<Copyable> : public etl::true_type
|
||||
{
|
||||
@ -148,11 +143,6 @@ struct etl::is_assignable<Moveable, Moveable> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_constructible<Moveable> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_copy_constructible<Moveable> : public etl::false_type
|
||||
{
|
||||
@ -169,11 +159,6 @@ struct etl::is_assignable<MoveableCopyable, MoveableCopyable> : public etl::true
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_constructible<MoveableCopyable> : public etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct etl::is_copy_constructible<MoveableCopyable> : public etl::true_type
|
||||
{
|
||||
|
||||
@ -634,31 +634,6 @@ namespace
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back)
|
||||
{
|
||||
Compare_Data compare_data;
|
||||
Data data;
|
||||
|
||||
for (int i = 0; i < int(SIZE); ++i)
|
||||
{
|
||||
compare_data.emplace_back(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(SIZE); ++i)
|
||||
{
|
||||
data.emplace_back(i);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(compare_data.size(), data.size());
|
||||
|
||||
bool is_equal = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_push_back_literal)
|
||||
{
|
||||
@ -697,6 +672,41 @@ namespace
|
||||
CHECK_THROW(data.push_back(SIZE), etl::vector_full);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back)
|
||||
{
|
||||
Compare_Data compare_data;
|
||||
Data data;
|
||||
|
||||
for (int i = 0; i < int(SIZE); ++i)
|
||||
{
|
||||
compare_data.emplace_back(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(SIZE); ++i)
|
||||
{
|
||||
data.emplace_back(i);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(compare_data.size(), data.size());
|
||||
|
||||
bool is_equal = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
|
||||
{
|
||||
Data data;
|
||||
|
||||
data.emplace_back(24);
|
||||
auto back = data.emplace_back(42);
|
||||
CHECK_EQUAL(back, data.back());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_pop_back)
|
||||
{
|
||||
|
||||
@ -685,6 +685,41 @@ namespace
|
||||
CHECK_THROW(data.push_back(SIZE), etl::vector_full);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back)
|
||||
{
|
||||
Compare_Data compare_data;
|
||||
Data data(buffer1, SIZE);
|
||||
|
||||
for (int i = 0; i < int(SIZE); ++i)
|
||||
{
|
||||
compare_data.emplace_back(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(SIZE); ++i)
|
||||
{
|
||||
data.emplace_back(i);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(compare_data.size(), data.size());
|
||||
|
||||
bool is_equal = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
|
||||
{
|
||||
Data data(buffer1, SIZE);
|
||||
|
||||
data.emplace_back(24);
|
||||
auto back = data.emplace_back(42);
|
||||
CHECK_EQUAL(back, data.back());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_pop_back)
|
||||
{
|
||||
|
||||
@ -662,29 +662,6 @@ namespace
|
||||
CHECK_THROW(data.push_back(NDC("Z")), etl::vector_full);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back)
|
||||
{
|
||||
CompareDataNDC compare_data;
|
||||
DataNDC data;
|
||||
|
||||
for (size_t i = 0UL; i < SIZE; ++i)
|
||||
{
|
||||
std::string value(" ");
|
||||
value[0] = char('A' + i);
|
||||
compare_data.emplace_back(value, i);
|
||||
data.emplace_back(value, i);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(compare_data.size(), data.size());
|
||||
|
||||
bool is_equal = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_push_back_unique_ptr)
|
||||
{
|
||||
@ -711,6 +688,39 @@ namespace
|
||||
CHECK_EQUAL(4, *data[3]);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back)
|
||||
{
|
||||
CompareDataNDC compare_data;
|
||||
DataNDC data;
|
||||
|
||||
for (size_t i = 0UL; i < SIZE; ++i)
|
||||
{
|
||||
std::string value(" ");
|
||||
value[0] = char('A' + i);
|
||||
compare_data.emplace_back(value, i);
|
||||
data.emplace_back(value, i);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(compare_data.size(), data.size());
|
||||
|
||||
bool is_equal = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
|
||||
{
|
||||
DataNDC data;
|
||||
|
||||
data.emplace_back("A", 24);
|
||||
auto back = data.emplace_back("B", 42);
|
||||
CHECK_EQUAL(back, data.back());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_insert_int)
|
||||
{
|
||||
|
||||
@ -1057,6 +1057,17 @@ namespace
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
|
||||
{
|
||||
Data data;
|
||||
int d1 = 22;
|
||||
int d2 = 42;
|
||||
|
||||
data.emplace_back(&d1);
|
||||
CHECK_EQUAL(&d2, data.emplace_back(&d2));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_pop_back)
|
||||
{
|
||||
|
||||
@ -1043,6 +1043,17 @@ namespace
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
|
||||
{
|
||||
Data data(buffer1, SIZE);
|
||||
int d1 = 42;
|
||||
int d2 = 24;
|
||||
|
||||
data.emplace_back(&d1);
|
||||
CHECK_EQUAL(&d2, data.emplace_back(&d2));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_pop_back)
|
||||
{
|
||||
|
||||
@ -5630,6 +5630,34 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\expected.h.t.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Small Strings|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - No STL - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Constexpr Algorithms|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM C++20|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No Unit Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - String Truncation Is Error|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Clang|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL - Force No Advanced|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force cpp03|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Intel - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Intel|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Checks|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force C++03|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\message_broker.h.t.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Small Strings|Win32'">true</ExcludedFromBuild>
|
||||
@ -11381,6 +11409,7 @@
|
||||
<ClCompile Include="..\test_crc8_maxim.cpp" />
|
||||
<ClCompile Include="..\test_crc8_rohc.cpp" />
|
||||
<ClCompile Include="..\test_crc8_wcdma.cpp" />
|
||||
<ClCompile Include="..\test_expected.cpp" />
|
||||
<ClCompile Include="..\test_message_broker.cpp" />
|
||||
<ClCompile Include="..\test_poly_span_dynamic_extent.cpp" />
|
||||
<ClCompile Include="..\test_poly_span_fixed_extent.cpp" />
|
||||
|
||||
@ -1344,6 +1344,9 @@
|
||||
<ClInclude Include="..\..\include\etl\optional.h">
|
||||
<Filter>ETL\Utilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\optional.h">
|
||||
<Filter>ETL\Utilities</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\test_string_char.cpp">
|
||||
@ -2228,9 +2231,6 @@
|
||||
<ClCompile Include="..\test_parameter_type.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_result.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_utility.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
@ -3392,6 +3392,15 @@
|
||||
<ClCompile Include="..\test_optional.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_result.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_expected.cpp">
|
||||
<Filter>Tests\Containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\expected.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks\Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\library.properties">
|
||||
|
||||
@ -1 +1 @@
|
||||
20.35.0
|
||||
20.35.10
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user