add static assert with auto message (#740)

* Resolve all C++ -O2 warnings

Resolve all C++ -O2 warnings

Resolve all C++ -O2 warnings

* Updated release notes and version

* Made unit test suite names unique

* Added etl::bit_v for C++17

* add stringify macro (#741)

* Add include/linux/stringify.h from Linux kernel 2.6.12-rc2

(cherry picked from commit 1da177e4c3)

* Make __stringify support variable argument macros too

For example:

  __stringify(__entry->irq, __entry->ret)

will now convert it to:

  "REC->irq, REC->ret"

It also still supports single arguments as the old macro did.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <49DC6751.30308@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
(cherry picked from commit 8f7c2c3731)

* Add documentation.

* Adjust names in order to satisfy naming convention.

* Use __VA_ARGS__ instead a GNU extension as this works with more compilers.

Works with the newest versions of ICCAVR, GCC, CLANG and MSCV. C++11 may be required.

* Adjust to ETL folder structure.

* Change include guard to the one usual in ETL.

* Add definition guard for STRINGIFY.

---------

Co-authored-by: Linus Torvalds <torvalds@ppc970.osdl.org>
Co-authored-by: Zhaolei <zhaolei@cn.fujitsu.com>

* Updated stringify macro for variadic parameters

* Edited comments

* Added multi char type strcmp, strncmp, strcpy & strncpy

* Added support for self transitions

* Remove some unreachable code in bitset_new.h (#743)

Warning[Pe111]: statement is unreachable

* Re-enabled tests for etl::string_ext

* Changes require for non-virtual messages

* MutexMessageRouter example

* Allow C++03 delegate in etl::callback_timer

* #745 Assertion triggered in hash.h when compiling for MSP430

* Removed redundant #includes

* Removed unused variable

Minor format edit

* Added time_to_next() status function

* Added 'sentence case' versions of constants

* Added C++03 compatible etl::move or etl::move_backward

* Added c++03 zero parameter emplace member functions

* Fix issue of release of an object on empty an pool

* Remove used variable

* Remove used variable

* Change to require semicolons after debug count macros.

Added error assert for vector reserve greater than capacity.

* Added destructor to CMSIS_RTOS2 mutex

* Updated version and release notes

* Removed semicolon warnings

* Updated vesrion and release notes

* #753 [porting] IAR's overload resolution struggles with etl::span::span(etl::array&)

#754 ambiguous etl::bit_stream_reader::bit_stream_reader() for some etl::span

* #755 warning about constexpr in array.h

* Re-enabled tests

* const_reference at(size_t i) const is only constexpr from C++14

* Added conversion operators to std::span

* MacOS clang span issue

* MacOS clang span issue

* MacOS clang span issue

* MacOS clang span issue

* MacOS clang span issue

* Updated version and release notes

* Possible fix for #756

* Fixed: move assignment not working for non-empty containers (#759)

* Updated release notes

* Make "private" includes relativ (#761)

Avoid "include not found" when indirectly including etl-header

Co-authored-by: Andreas Pelczer <pelczer@stoerk-tronic.com>

* Make "private" includes relativ (#761)

Avoid "include not found" when indirectly including etl-header

Co-authored-by: Andreas Pelczer <pelczer@stoerk-tronic.com>

* Remove BOM from random.h (#762)

random.h is the only file with UTF8-BOM and IAR can not handle it.
For compatibility reasons it should be removed.

Co-authored-by: Andreas Pelczer <pelczer@stoerk-tronic.com>

* Enabled etl::overload for C++11 & C++14

* Added conversion operators to std::span

MacOS clang span issue

MacOS clang span issue

MacOS clang span issue

MacOS clang span issue

MacOS clang span issue

* Updated version and release notes

* Possible fix for #756

* Fixed: move assignment not working for non-empty containers (#759)

* Updated release notes

* Make "private" includes relativ (#761)

Avoid "include not found" when indirectly including etl-header

Co-authored-by: Andreas Pelczer <pelczer@stoerk-tronic.com>

* Remove BOM from random.h (#762)

random.h is the only file with UTF8-BOM and IAR can not handle it.
For compatibility reasons it should be removed.

Co-authored-by: Andreas Pelczer <pelczer@stoerk-tronic.com>

* Enabled etl::overload for C++11 & C++14

* Commets added

* #766 etl::unique_ptr::reset() can call deleter with nullptr argument

* Refactored storage for etl::optional

* Updated release notes

* Updated release notes

* Test name updates

* Fixed alignment functionality

* Updated versions

* Updated versions

* Initial code

* Final changes

* Fix maybe-uninitialized warning

* Fix maybe-uninitialized warning

* Added etl::string::fill()

* Added etl::string interface to etl::base64

* static_cast for string_view & array_view size() member functions

* Return raw pointer for `etl::multi_span::operator->()`. (#773)

- using `operator*()` in case getting the current element is changed one day
- using `&` to get the address

Simply returning `p_value` may break in case the internal type of `p_value` would change. This way it is more robust to changes.

* Added -> operator test

* #773 Return raw pointer for etl::multi_span::operator->()

* static_cast for string_view & array_view size() member functions

* Initial code

* Final changes

* Fix maybe-uninitialized warning

* Added etl::string::fill()

* Added etl::string interface to etl::base64

* Add missing semicolons (#776)

* #776 Add missing semicolons

* moved BUILD_TESTS check outside of root cmake check to allow building tests in submodules (#777)

added check for GNUC >= 11 for -Wstringop-overread ignore pragma since it isn't introduced until gcc/g++-11

Co-authored-by: Josh <joshua.martens@magna.com>

* Try to fix library error for Github Actions for Clang C++20

* Try to fix library error for Github Actions for Clang C++20

* Added pul-request branches to CI

* Removed temporary fix

* Refactored swap

* Added add_lvalue_reference for rvalue reference

* Revert "Added add_lvalue_reference for rvalue reference"

This reverts commit a09efffb8fadb0c25923fe5435b7b1f9bdd673f1.

* Updated  version and release notes

* Updated  version and release notes

* Try to fix library error for Github Actions for Clang C++20

(cherry picked from commit f208eb4073c98b3c190b17a73db3b61aa35fae25)

The line got lost in 95c7f44cc61d51406a70ccb9048724f9fbdd78f9.

* Add helper macro which enables function-like macro overload with 1 or 2 arguments.

Inspired by https://stackoverflow.com/a/11763277/

Warning: This requires support for variadic macros (`__VA_ARGS__`). These were officially added in C99 and C++11.

* Add unit test for static_assert.h

(cherry picked from commit 91e7f46effac2884de80a12ab0c7eda5ade5cabe)

* Add static assert overload for only 1 argument.

(cherry picked from commit ae8c19e8cba69ca209a13109a7225ce6281d945d)

* Add test case for static_assert with only 1 argument.

(cherry picked from commit 4d6e7a63094221feec22fe3addcccd903b2d81de)

* Spelling.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: David Hebbeker <dhebbeker@users.noreply.github.com>
Co-authored-by: Linus Torvalds <torvalds@ppc970.osdl.org>
Co-authored-by: Zhaolei <zhaolei@cn.fujitsu.com>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: Soma Veszelovszki <soma.veszelovszki@gmail.com>
Co-authored-by: Andreas <and1p@web.de>
Co-authored-by: Andreas Pelczer <pelczer@stoerk-tronic.com>
Co-authored-by: H1MSK <ksda47832338@Outlook.com>
Co-authored-by: jmartens-42 <jmartens@jayhawk.us>
Co-authored-by: Josh <joshua.martens@magna.com>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
This commit is contained in:
David Hebbeker 2024-02-22 20:11:38 +01:00 committed by GitHub
parent f9da1cde9b
commit 3392a6cd88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
198 changed files with 17746 additions and 18593 deletions

View File

@ -1,9 +1,9 @@
name: clang syntax checks
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]
jobs:
build-clang-cpp03-linux-STL:

View File

@ -1,11 +1,12 @@
name: clang
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]
jobs:
build-clang-cpp11-linux-stl:
name: Clang C++11 Linux - STL
runs-on: ${{ matrix.os }}

View File

@ -1,9 +1,9 @@
name: gcc syntax checks
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]
jobs:
build-gcc-cpp03-linux-STL:

View File

@ -1,9 +1,9 @@
name: gcc
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]
jobs:
build-gcc-cpp11-linux-stl:

View File

@ -1,9 +1,9 @@
name: msvc
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]
jobs:
build-windows-msvc-stl:

4
.gitignore vendored
View File

@ -382,3 +382,7 @@ test/vs2022/Release MSVC C++20 - No STL - Optimised -O2
test/vs2022/Release MSVC C++20 - Optimised O2
test/vs2022/Debug MSVC C++ 20 - No Tests
test/vs2022/enc_temp_folder
test/vs2022/Debug MSVC C++20 - No virtual messages
examples/MutexMessageRouter/.vs
support/time remaining test.xlsx
test/vs2022/Debug MSVC C++20 - Force C++03

View File

@ -73,9 +73,10 @@ 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)
if (BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
endif()
if (BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library - Arduino",
"version": "20.37.3",
"version": "20.38.4",
"authors": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library - Arduino
version=20.37.3
version=20.38.4
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.5.0)
project(etl_mutex_router LANGUAGES CXX)
add_executable(etl_mutex_router MutexMessageRouter.cpp)
target_compile_definitions(etl_mutex_router PRIVATE -DETL_DEBUG)
target_include_directories(etl_mutex_router
PRIVATE
${PROJECT_SOURCE_DIR}/../../include)
set_property(TARGET etl_mutex_router PROPERTY CXX_STANDARD 17)

View File

@ -0,0 +1,110 @@
#include <iostream>
#include <thread>
#include <atomic>
#include <string>
#include <chrono>
#include "etl/mutex.h"
#include "etl/message.h"
#include "etl/message_router.h"
//*************************************
struct Message1 : public etl::message<1>
{
};
//*************************************
struct Message2 : public etl::message<2>
{
};
//*************************************
class Router : public etl::message_router<Router, Message1, Message2>
{
public:
using base_t = etl::message_router<Router, Message1, Message2>;
//*****************
// Overridden receive that protects access with mutexes
void receive(const etl::imessage& msg) override
{
access.lock();
base_t::receive(msg); // Send it to the message_router's receive.
access.unlock();
}
//*****************
void on_receive(const Message1&)
{
result.append("Message1\n");
}
//*****************
void on_receive(const Message2&)
{
result.append("Message2\n");
}
//*****************
void on_receive_unknown(const etl::imessage&)
{
}
std::string result;
private:
etl::mutex access;
};
//*************************************
etl::atomic<bool> start = false;
Router router;
//*************************************
void thread1()
{
using namespace std::chrono_literals;
while (!start.load());
for (int i = 0; i < 10; ++i)
{
std::this_thread::sleep_for(1ms);
router.receive(Message1());
}
}
//*************************************
void thread2()
{
using namespace std::chrono_literals;
while (!start.load());
for (int i = 0; i < 10; ++i)
{
std::this_thread::sleep_for(1ms);
router.receive(Message2());
}
}
//*************************************
int main()
{
std::thread t1(thread1);
std::thread t2(thread2);
start.store(true);
t1.join();
t2.join();
std::cout << router.result << "\n";
return 0;
}

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34009.444
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MutexMessageRouter", "MutexMessageRouter.vcxproj", "{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x64.ActiveCfg = Debug|x64
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x64.Build.0 = Debug|x64
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x86.ActiveCfg = Debug|Win32
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x86.Build.0 = Debug|Win32
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x64.ActiveCfg = Release|x64
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x64.Build.0 = Release|x64
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x86.ActiveCfg = Release|Win32
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8AA5CBFE-B15F-4262-97AE-C12F7266BD85}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{23ad62d5-c3b6-48b0-bf0d-e349feb3f338}</ProjectGuid>
<RootNamespace>MutexMessageRouter</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../include;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="MutexMessageRouter.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -88,6 +88,37 @@ namespace etl
//*****************************************************************************
namespace etl
{
namespace private_algorithm
{
template <bool use_swap>
struct swap_impl;
// Generic swap
template <>
struct swap_impl<false>
{
template <typename TIterator1, typename TIterator2>
static void do_swap(TIterator1 a, TIterator2 b)
{
typename etl::iterator_traits<TIterator1>::value_type tmp = *a;
*a = *b;
*b = tmp;
}
};
// Specialised swap
template <>
struct swap_impl<true>
{
template <typename TIterator1, typename TIterator2>
static void do_swap(TIterator1 a, TIterator2 b)
{
using ETL_OR_STD::swap; // Allow ADL
swap(*a, *b);
}
};
}
//***************************************************************************
// iter_swap
//***************************************************************************
@ -99,8 +130,20 @@ namespace etl
#endif
void iter_swap(TIterator1 a, TIterator2 b)
{
using ETL_OR_STD::swap; // Allow ADL
swap(*a, *b);
typedef etl::iterator_traits<TIterator1> traits1;
typedef etl::iterator_traits<TIterator2> traits2;
typedef typename traits1::value_type v1;
typedef typename traits2::value_type v2;
typedef typename traits1::reference r1;
typedef typename traits2::reference r2;
const bool use_swap = etl::is_same<v1, v2>::value &&
etl::is_reference<r1>::value &&
etl::is_reference<r2>::value;
private_algorithm::swap_impl<use_swap>::do_swap(a, b);
}
//***************************************************************************
@ -229,8 +272,8 @@ namespace etl
{
return std::move(sb, se, db);
}
#else
// non-pointer or not trivially copyable
#elif ETL_USING_CPP11
// For C++11
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
{
@ -243,19 +286,25 @@ namespace etl
return db;
}
#else
// For C++03
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
{
return copy(sb, se, db);
}
#endif
//***************************************************************************
// move_backward
#if ETL_USING_STL && ETL_USING_CPP20
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR20
TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
ETL_CONSTEXPR20 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{
return std::move_backward(sb, se, de);
}
#else
// non-pointer or not trivially copyable
#elif ETL_USING_CPP11
// For C++11
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{
@ -266,6 +315,13 @@ namespace etl
return de;
}
#else
// For C++03
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{
return etl::copy_backward(sb, se, de);
}
#endif
//***************************************************************************

View File

@ -204,13 +204,24 @@ namespace etl
{
public:
#if ETL_NOT_USING_64BIT_TYPES
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
#if ETL_USING_CPP11
typedef struct { alignas(Alignment) char dummy; } type;
#else
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
#if ETL_NOT_USING_64BIT_TYPES
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
#else
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
#endif
#endif
ETL_STATIC_ASSERT(etl::alignment_of<type>::value == Alignment, "Unable to create the type with the specified alignment");
};
#if ETL_USING_CPP11
template <size_t Alignment>
using type_with_alignment_t = typename type_with_alignment<Alignment>::type;
#endif
//***************************************************************************
/// Aligned storage
/// Length should be determined in terms of sizeof()

View File

@ -127,11 +127,7 @@ namespace etl
///\param i The index of the element to access.
//*************************************************************************
ETL_NODISCARD
#if defined(ETL_THROW_EXCEPTIONS)
ETL_CONSTEXPR14
#else
ETL_CONSTEXPR
#endif
const_reference at(size_t i) const
{
ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));

View File

@ -421,7 +421,7 @@ namespace etl
//*************************************************************************
/// Returns <b>true</b> if the array size is zero.
//*************************************************************************
bool empty() const
ETL_CONSTEXPR bool empty() const
{
return (mbegin == mend);
}
@ -429,15 +429,15 @@ namespace etl
//*************************************************************************
/// Returns the size of the array.
//*************************************************************************
size_t size() const
ETL_CONSTEXPR size_t size() const
{
return (mend - mbegin);
return static_cast<size_t>(mend - mbegin);
}
//*************************************************************************
/// Returns the maximum possible size of the array.
//*************************************************************************
size_t max_size() const
ETL_CONSTEXPR size_t max_size() const
{
return size();
}

523
include/etl/base64.h Normal file
View File

@ -0,0 +1,523 @@
//*************************************************************************
///Decode from Base64 from and to pointer/length
//*************************************************************************///\file
/******************************************************************************
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.
******************************************************************************/
#ifndef ETL_BASE64_INCLUDED
#define ETL_BASE64_INCLUDED
#include "etl/platform.h"
#include "etl/span.h"
#include "etl/static_assert.h"
#include "etl/error_handler.h"
#include "etl/exception.h"
#include "etl/type_traits.h"
#include "etl/binary.h"
#include "etl/algorithm.h"
#include "etl/integral_limits.h"
#include "etl/iterator.h"
#include "etl/string.h"
#include <stdint.h>
#if ETL_USING_STL
#include <string>
#endif
namespace etl
{
//***************************************************************************
/// Exception base for base64
//***************************************************************************
class base64_exception : public etl::exception
{
public:
base64_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
: exception(reason_, file_name_, line_number_)
{
}
};
//***************************************************************************
/// Memory misalignment exception.
//***************************************************************************
class base64_overflow : public base64_exception
{
public:
base64_overflow(string_type file_name_, numeric_type line_number_)
: base64_exception(ETL_ERROR_TEXT("base64:overflow", ETL_BASE64_FILE_ID"A"), file_name_, line_number_)
{
}
};
//*************************************************************************
/// Codec for Base64
//*************************************************************************
class base64
{
public:
//*************************************************************************
/// Encode to Base64 from and to pointer/length
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
encode(const T* input, size_t input_length, char* output, size_t output_length)
{
if (input_length == 0U)
{
return 0;
}
// Figure out if the output buffer is large enough.
size_t required_output_length = encode_size(input_length);
ETL_ASSERT_OR_RETURN_VALUE(output_length >= required_output_length, ETL_ERROR(base64_overflow), 0U);
const T* p_in = input;
const T* p_in_end = input + input_length;
char* p_out = output;
char* p_out_end = output + required_output_length;
int next_sextet = First_Sextet;
// Step through the input buffer, creating the output sextets.
while (p_in != p_in_end)
{
T c = *p_in;
char index = 0;
switch (next_sextet)
{
//**************************
case First_Sextet:
{
index = static_cast<char>((*p_in & b11111100) >> 2);
next_sextet = Second_Sextet;
break;
}
//**************************
case Second_Sextet:
{
index = static_cast<char>((c & b00000011) << 4);
++p_in;
// Next byte valid?
if (p_in != p_in_end)
{
index = index | ((*p_in & b11110000) >> 4);
}
next_sextet = Third_Sextet;
break;
}
//**************************
case Third_Sextet:
{
index = (c & b00001111) << 2;
++p_in;
// Next byte valid?
if (p_in != p_in_end)
{
index = index | static_cast<char>((*p_in & b11000000) >> 6);
}
next_sextet = Fourth_Sextet;
break;
}
//**************************
case Fourth_Sextet:
{
index = static_cast<char>(c & b00111111);
++p_in;
next_sextet = First_Sextet;
break;
}
//**************************
default:
{
// Should never get here.
assert(false);
break;
}
}
*p_out = get_sextet_from_index(index);
++p_out;
}
// Pad out the end of the output buffer.
while (p_out != p_out_end)
{
*p_out++ = padding();
}
return static_cast<size_t>(etl::distance(output, p_out));
}
//*************************************************************************
/// Encode to Base64 from and to pointer/pointer
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
encode(const T* input_begin, const T* input_end, char* output_begin, char* output_end)
{
return encode(input_begin, static_cast<size_t>(etl::distance(input_begin, input_end)),
output_begin, static_cast<size_t>(etl::distance(output_begin, output_end)));
}
//*************************************************************************
/// Encode to Base64 from and to span/span
//*************************************************************************
template <typename T, size_t Length1, size_t Length2>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
encode(const etl::span<const T, Length1>& input_span,
const etl::span<char, Length2>& output_span)
{
return encode(input_span.begin(), input_span.size(),
output_span.begin(), output_span.size());
}
//*************************************************************************
/// Encode to Base64 from pointer/length to etl::istring
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
encode(const T* input_begin, size_t input_length,
etl::istring& output)
{
output.resize(etl::base64::encode_size(input_length));
return encode(input_begin, input_length,
output.data(), output.size());
}
//*************************************************************************
/// Encode to Base64 from pointer/pointer to etl::istring
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
encode(const T* input_begin, const T* input_end,
etl::istring& output)
{
output.resize(etl::base64::encode_size(etl::distance(input_begin, input_end)));
return encode(input_begin, static_cast<size_t>(etl::distance(input_begin, input_end)),
output.data(), output.size());
}
//*************************************************************************
/// Encode to Base64 from span to etl::istring
//*************************************************************************
template <typename T, size_t Length1>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
encode(const etl::span<const T, Length1>& input_span,
etl::istring& output)
{
output.resize(etl::base64::encode_size(Length1));
return encode(input_span.begin(), input_span.size(),
output.data(), output.size());
}
//*************************************************************************
/// Calculates the buffer size required to encode to Base64
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
static
size_t encode_size(size_t input_length)
{
size_t required_output_length = (input_length * 8U) / 6U;
if ((input_length % 3U) != 0U)
{
while ((required_output_length % 4U) != 0)
{
++required_output_length;
}
}
return required_output_length;
}
//*************************************************************************
/// Decode from Base64 from and to pointer/length
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
decode(const char* input, size_t input_length, T* output, size_t output_length)
{
if (input_length == 0)
{
return 0;
}
// Figure out if the output buffer is large enough.
size_t required_output_length = etl::base64::decode_size(input, input_length);
ETL_ASSERT_OR_RETURN_VALUE(output_length >= required_output_length, ETL_ERROR(base64_overflow), 0U);
const char* p_in = input;
const char* p_in_end = input + input_length;
T* p_out = output;
T c = 0;
int next_sextet = First_Sextet;
// Step through the input buffer, creating the output binary.
while (p_in != p_in_end)
{
char sextet = *p_in++; // Get the sextet as a T.
if (sextet == padding())
{
break;
}
char index = get_index_from_sextet(sextet);
switch (next_sextet)
{
//**************************
case First_Sextet:
{
c = (index & b00111111) << 2;
next_sextet = Second_Sextet;
break;
}
//**************************
case Second_Sextet:
{
c |= (index & b00110000) >> 4;
*p_out++ = static_cast<T>(c);
c = (index & b00001111) << 4;
next_sextet = Third_Sextet;
break;
}
//**************************
case Third_Sextet:
{
c |= (index & b00111100) >> 2;
*p_out++ = static_cast<T>(c);
c = (index & b00000011) << 6;
next_sextet = Fourth_Sextet;
break;
}
//**************************
case Fourth_Sextet:
{
c |= (index & b00111111);
*p_out++ = static_cast<T>(c);
next_sextet = First_Sextet;
break;
}
//**************************
default:
{
// Should never get here.
assert(false);
break;
}
}
}
return static_cast<size_t>(etl::distance(output, p_out));
}
//*************************************************************************
/// Decode from Base64 from and to pointer/pointer
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
decode(const char* input_begin, const char* input_end, T* output_begin, T* output_end)
{
return decode(input_begin, static_cast<size_t>(etl::distance(input_begin, input_end)),
output_begin, static_cast<size_t>(etl::distance(output_begin, output_end)));
}
//*************************************************************************
/// Decode from Base64 from and to span/span
//*************************************************************************
template <typename T, size_t Length1, size_t Length2>
ETL_CONSTEXPR14
static
typename etl::enable_if<etl::is_integral<T>::value && (etl::integral_limits<T>::bits == 8U), size_t>::type
decode(const etl::span<const char, Length1>& input_span,
const etl::span<T, Length2>& output_span)
{
return decode(input_span.begin(), input_span.size(),
output_span.begin(), output_span.size());
}
//*************************************************************************
/// Calculates the buffer size required to decode from Base64
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
static size_t decode_size(const char* input, size_t input_length)
{
if (input_length == 0U)
{
return 0U;
}
// Figure out the minimum output buffer size.
size_t length = static_cast<size_t>(etl::distance(input, etl::find(input, input + input_length, padding())) - 1);
size_t required_output_length = length - (length / 4U);
return required_output_length;
}
private:
//*************************************************************************
/// Sextet index id.
enum
{
First_Sextet,
Second_Sextet,
Third_Sextet,
Fourth_Sextet
};
// Sextets
// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
// 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
// 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
// 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
// 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
// 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
// 'w', 'x', 'y', 'z', '0', '1', '2', '3',
// '4', '5', '6', '7', '8', '9', '+', '/'
//*************************************************************************
// Translates an index into a sextet
//*************************************************************************
ETL_CONSTEXPR14 static char get_sextet_from_index(char index)
{
if ((index >= 0) && (index < 26))
{
return 'A' + index;
}
else if ((index >= 26) && (index < 52))
{
index -= 26;
return 'a' + index;
}
else if ((index >= 52) && (index < 62))
{
index -= 52;
return '0' + index;
}
else if (index == 62)
{
return '+';
}
else if (index == 63)
{
return '/';
}
else
{
// Should never get here.
assert(false);
return padding();
}
}
//*************************************************************************
// Translates a sextet into an index
//*************************************************************************
ETL_CONSTEXPR14 static char get_index_from_sextet(char sextet)
{
if ((sextet >= 'A') && (sextet <= 'Z'))
{
return sextet - 'A';
}
else if ((sextet >= 'a') && (sextet <= 'z'))
{
return sextet - 'a' + 26;
}
else if ((sextet >= '0') && (sextet <= '9'))
{
return sextet - '0' + 52;
}
else if (sextet == '+')
{
return 62;
}
else if (sextet == '/')
{
return 63;
}
else
{
// Should never get here.
assert(false);
return 0;
}
}
//*************************************************************************
/// Gets the padding character
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
static char padding()
{
return '=';
}
};
}
#endif

View File

@ -173,7 +173,7 @@ namespace etl
/// Gets the current size of the string.
///\return The current size of the string.
//*************************************************************************
size_type size() const
ETL_CONSTEXPR size_type size() const
{
return current_size;
}
@ -502,6 +502,16 @@ namespace etl
p_buffer[new_size] = 0;
}
//*********************************************************************
/// Fills the string with the specified character.
/// Does not change the string length.
///\param value The character used to fill the string.
//*********************************************************************
void fill(T value)
{
etl::fill(begin(), end(), value);
}
//*********************************************************************
/// Returns a reference to the value at index 'i'
///\param i The index.
@ -595,7 +605,7 @@ namespace etl
/// Returns a const pointer to the beginning of the string data.
///\return A const pointer to the beginning of the string data.
//*********************************************************************
const_pointer data() const
ETL_CONSTEXPR const_pointer data() const
{
return p_buffer;
}
@ -703,7 +713,7 @@ namespace etl
set_truncated(*other != 0);
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation))
ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation));
#endif
#endif
@ -724,7 +734,7 @@ namespace etl
set_truncated(length_ > CAPACITY);
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation))
ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation));
#endif
#endif
@ -764,7 +774,7 @@ namespace etl
set_truncated(first != last);
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation))
ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation));
#endif
#endif
}
@ -783,7 +793,7 @@ namespace etl
set_truncated(n > CAPACITY);
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation))
ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation));
#endif
#endif

View File

@ -390,16 +390,21 @@ namespace etl
template <size_t POSITION>
struct bit
{
typedef typename etl::smallest_uint_for_bits<POSITION + 1>::type value_type;
typedef typename etl::smallest_uint_for_bits<POSITION + 1U>::type value_type;
static ETL_CONSTANT value_type value = value_type(1) << POSITION;
};
template <size_t POSITION>
ETL_CONSTANT typename bit<POSITION>::value_type bit<POSITION>::value;
#if ETL_USING_CPP11
template <size_t POSITION>
using bit_t = typename etl::bit<POSITION>::value_type;
#endif
#if ETL_USING_CPP17
template <size_t POSITION>
inline constexpr typename bit<POSITION>::value_type bit_v = bit<POSITION>::value;
inline constexpr bit_t<POSITION> bit_v = etl::bit<POSITION>::value;
#endif
//***************************************************************************

View File

@ -535,7 +535,8 @@ namespace etl
//***************************************************************************
/// Construct from span.
//***************************************************************************
bit_stream_writer(etl::span<char> span_, etl::endian stream_endianness_, callback_type callback_ = callback_type())
template <size_t Length>
bit_stream_writer(const etl::span<char, Length>& span_, etl::endian stream_endianness_, callback_type callback_ = callback_type())
: pdata(span_.begin())
, length_chars(span_.size_bytes())
, stream_endianness(stream_endianness_)
@ -547,7 +548,8 @@ namespace etl
//***************************************************************************
/// Construct from span.
//***************************************************************************
bit_stream_writer(etl::span<unsigned char> span_, etl::endian stream_endianness_, callback_type callback_ = callback_type())
template <size_t Length>
bit_stream_writer(const etl::span<unsigned char, Length>& span_, etl::endian stream_endianness_, callback_type callback_ = callback_type())
: pdata(reinterpret_cast<char*>(span_.begin()))
, length_chars(span_.size_bytes())
, stream_endianness(stream_endianness_)
@ -1031,7 +1033,8 @@ namespace etl
//***************************************************************************
/// Construct from span.
//***************************************************************************
bit_stream_reader(etl::span<char> span_, etl::endian stream_endianness_)
template <size_t Length>
bit_stream_reader(const etl::span<char, Length>& span_, etl::endian stream_endianness_)
: pdata(span_.begin())
, length_chars(span_.size_bytes())
, stream_endianness(stream_endianness_)
@ -1042,8 +1045,33 @@ namespace etl
//***************************************************************************
/// Construct from span.
//***************************************************************************
bit_stream_reader(etl::span<unsigned char> span_, etl::endian stream_endianness_)
: pdata(reinterpret_cast<char*>(span_.begin()))
template <size_t Length>
bit_stream_reader(const etl::span<unsigned char, Length>& span_, etl::endian stream_endianness_)
: pdata(reinterpret_cast<const char*>(span_.begin()))
, length_chars(span_.size_bytes())
, stream_endianness(stream_endianness_)
{
restart();
}
//***************************************************************************
/// Construct from span.
//***************************************************************************
template <size_t Length>
bit_stream_reader(const etl::span<const char, Length>& span_, etl::endian stream_endianness_)
: pdata(span_.begin())
, length_chars(span_.size_bytes())
, stream_endianness(stream_endianness_)
{
restart();
}
//***************************************************************************
/// Construct from span.
//***************************************************************************
template <size_t Length>
bit_stream_reader(const etl::span<const unsigned char, Length>& span_, etl::endian stream_endianness_)
: pdata(reinterpret_cast<const char*>(span_.begin()))
, length_chars(span_.size_bytes())
, stream_endianness(stream_endianness_)
{
@ -1054,8 +1082,8 @@ namespace etl
/// Construct from range.
//***************************************************************************
bit_stream_reader(void* begin_, void* end_, etl::endian stream_endianness_)
: pdata(reinterpret_cast<char*>(begin_))
, length_chars(etl::distance(reinterpret_cast<char*>(begin_), reinterpret_cast<char*>(end_)))
: pdata(reinterpret_cast<const char*>(begin_))
, length_chars(etl::distance(reinterpret_cast<const char*>(begin_), reinterpret_cast<const char*>(end_)))
, stream_endianness(stream_endianness_)
{
restart();
@ -1065,7 +1093,7 @@ namespace etl
/// Construct from begin and length.
//***************************************************************************
bit_stream_reader(void* begin_, size_t length_, etl::endian stream_endianness_)
: pdata(reinterpret_cast<char*>(begin_))
: pdata(reinterpret_cast<const char*>(begin_))
, length_chars(length_)
, stream_endianness(stream_endianness_)
{
@ -1318,7 +1346,7 @@ namespace etl
bits_available -= nbits;
}
char* pdata; ///< The start of the bitstream buffer.
const char* pdata; ///< The start of the bitstream buffer.
size_t length_chars; ///< The length, in char, of the bitstream buffer.
const etl::endian stream_endianness; ///< The endianness of the stream data.
unsigned char bits_available_in_char; ///< The number of available bits in the current char.

View File

@ -94,7 +94,7 @@ namespace etl
callback_timer_data()
: p_callback(ETL_NULLPTR),
period(0),
delta(etl::timer::state::INACTIVE),
delta(etl::timer::state::Inactive),
id(etl::timer::id::NO_TIMER),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
@ -112,7 +112,7 @@ namespace etl
bool repeating_)
: p_callback(reinterpret_cast<void*>(p_callback_)),
period(period_),
delta(etl::timer::state::INACTIVE),
delta(etl::timer::state::Inactive),
id(id_),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
@ -130,7 +130,7 @@ namespace etl
bool repeating_)
: p_callback(reinterpret_cast<void*>(&callback_)),
period(period_),
delta(etl::timer::state::INACTIVE),
delta(etl::timer::state::Inactive),
id(id_),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
@ -139,7 +139,6 @@ namespace etl
{
}
#if ETL_USING_CPP11
//*******************************************
/// ETL delegate callback
//*******************************************
@ -149,7 +148,7 @@ namespace etl
bool repeating_)
: p_callback(reinterpret_cast<void*>(&callback_)),
period(period_),
delta(etl::timer::state::INACTIVE),
delta(etl::timer::state::Inactive),
id(id_),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
@ -157,14 +156,13 @@ namespace etl
cbk_type(DELEGATE)
{
}
#endif
//*******************************************
/// Returns true if the timer is active.
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
return delta != etl::timer::state::Inactive;
}
//*******************************************
@ -172,7 +170,7 @@ namespace etl
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
delta = etl::timer::state::Inactive;
}
void* p_callback;
@ -315,7 +313,7 @@ namespace etl
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
timer.delta = etl::timer::state::Inactive;
}
//*******************************
@ -324,6 +322,12 @@ namespace etl
return ptimers[head];
}
//*******************************
const etl::callback_timer_data& front() const
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{
@ -587,13 +591,11 @@ namespace etl
// Call the function wrapper callback.
(*reinterpret_cast<etl::ifunction<void>*>(timer.p_callback))();
}
#if ETL_USING_CPP11
else if(timer.cbk_type == callback_timer_data::DELEGATE)
{
// Call the delegate callback.
(*reinterpret_cast<callback_type*>(timer.p_callback))();
}
#endif
}
has_active = !active_list.empty();
@ -629,7 +631,7 @@ namespace etl
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
if (timer.period != etl::timer::state::Inactive)
{
ETL_DISABLE_TIMER_UPDATES;
if (timer.is_active())
@ -706,6 +708,16 @@ namespace etl
return false;
}
//*******************************************
/// Get the time to the next timer event.
//*******************************************
uint32_t time_to_next() const
{
uint32_t delta = active_list.front().delta;
return delta;
}
protected:
//*******************************************
@ -744,7 +756,7 @@ namespace etl
#endif
#endif
etl::timer_semaphore_t process_semaphore;
mutable etl::timer_semaphore_t process_semaphore;
#endif
uint_least8_t registered_timers;

View File

@ -220,7 +220,7 @@ namespace etl
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
if (timer.period != etl::timer::state::Inactive)
{
++process_semaphore;
if (timer.is_active())
@ -297,6 +297,18 @@ namespace etl
return false;
}
//*******************************************
/// Get the time to the next timer event.
//*******************************************
uint32_t time_to_next() const
{
++process_semaphore;
uint32_t delta = active_list.front().delta;
--process_semaphore;
return delta;
}
protected:
//*************************************************************************
@ -307,7 +319,7 @@ namespace etl
timer_data()
: callback()
, period(0U)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, id(etl::timer::id::NO_TIMER)
, previous(etl::timer::id::NO_TIMER)
, next(etl::timer::id::NO_TIMER)
@ -324,7 +336,7 @@ namespace etl
bool repeating_)
: callback(callback_)
, period(period_)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, id(id_)
, previous(etl::timer::id::NO_TIMER)
, next(etl::timer::id::NO_TIMER)
@ -337,7 +349,7 @@ namespace etl
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
return delta != etl::timer::state::Inactive;
}
//*******************************************
@ -345,7 +357,7 @@ namespace etl
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
delta = etl::timer::state::Inactive;
}
callback_type callback;
@ -500,7 +512,7 @@ namespace etl
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
timer.delta = etl::timer::state::Inactive;
}
//*******************************
@ -509,6 +521,12 @@ namespace etl
return ptimers[head];
}
//*******************************
const timer_data& front() const
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{
@ -563,7 +581,7 @@ namespace etl
timer_list active_list;
bool enabled;
TSemaphore process_semaphore;
mutable TSemaphore process_semaphore;
uint_least8_t number_of_registered_timers;
public:

View File

@ -221,7 +221,7 @@ namespace etl
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
if (timer.period != etl::timer::state::Inactive)
{
TInterruptGuard guard;
(void)guard; // Silence 'unused variable warnings.
@ -300,6 +300,19 @@ namespace etl
return false;
}
//*******************************************
/// Get the time to the next timer event.
//*******************************************
uint32_t time_to_next() const
{
TInterruptGuard guard;
(void)guard; // Silence 'unused variable warnings.
uint32_t delta = active_list.front().delta;
return delta;
}
protected:
//*************************************************************************
@ -310,7 +323,7 @@ namespace etl
timer_data()
: callback()
, period(0U)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, id(etl::timer::id::NO_TIMER)
, previous(etl::timer::id::NO_TIMER)
, next(etl::timer::id::NO_TIMER)
@ -327,7 +340,7 @@ namespace etl
bool repeating_)
: callback(callback_)
, period(period_)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, id(id_)
, previous(etl::timer::id::NO_TIMER)
, next(etl::timer::id::NO_TIMER)
@ -340,7 +353,7 @@ namespace etl
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
return delta != etl::timer::state::Inactive;
}
//*******************************************
@ -348,7 +361,7 @@ namespace etl
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
delta = etl::timer::state::Inactive;
}
callback_type callback;
@ -370,11 +383,11 @@ namespace etl
/// Constructor.
//*******************************************
icallback_timer_interrupt(timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_)
: timer_array(timer_array_),
active_list(timer_array_),
enabled(false),
number_of_registered_timers(0U),
MAX_TIMERS(MAX_TIMERS_)
: timer_array(timer_array_)
, active_list(timer_array_)
, enabled(false)
, number_of_registered_timers(0U)
, MAX_TIMERS(MAX_TIMERS_)
{
}
@ -501,8 +514,8 @@ namespace etl
}
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::Inactive;
}
//*******************************
@ -511,6 +524,12 @@ namespace etl
return ptimers[head];
}
//*******************************
const timer_data& front() const
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{
@ -544,8 +563,8 @@ namespace etl
timer.next = etl::timer::id::NO_TIMER;
}
head = etl::timer::id::NO_TIMER;
tail = etl::timer::id::NO_TIMER;
head = etl::timer::id::NO_TIMER;
tail = etl::timer::id::NO_TIMER;
current = etl::timer::id::NO_TIMER;
}

View File

@ -222,7 +222,7 @@ namespace etl
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
if (timer.period != etl::timer::state::Inactive)
{
lock();
if (timer.is_active())
@ -309,6 +309,18 @@ namespace etl
unlock = unlock_;
}
//*******************************************
/// Get the time to the next timer event.
//*******************************************
uint32_t time_to_next() const
{
lock();
uint32_t delta = active_list.front().delta;
unlock();
return delta;
}
protected:
//*************************************************************************
@ -319,7 +331,7 @@ namespace etl
timer_data()
: callback()
, period(0U)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, id(etl::timer::id::NO_TIMER)
, previous(etl::timer::id::NO_TIMER)
, next(etl::timer::id::NO_TIMER)
@ -336,7 +348,7 @@ namespace etl
bool repeating_)
: callback(callback_)
, period(period_)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, id(id_)
, previous(etl::timer::id::NO_TIMER)
, next(etl::timer::id::NO_TIMER)
@ -349,7 +361,7 @@ namespace etl
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
return delta != etl::timer::state::Inactive;
}
//*******************************************
@ -357,7 +369,7 @@ namespace etl
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
delta = etl::timer::state::Inactive;
}
callback_type callback;
@ -511,7 +523,7 @@ namespace etl
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
timer.delta = etl::timer::state::Inactive;
}
//*******************************
@ -520,6 +532,12 @@ namespace etl
return ptimers[head];
}
//*******************************
const timer_data& front() const
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{

View File

@ -264,7 +264,7 @@ namespace etl
/// Alternative strlen for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR size_t strlen(const T* t)
ETL_CONSTEXPR14 size_t strlen(const T* t)
{
return etl::char_traits<T>::length(t);
}
@ -273,10 +273,97 @@ namespace etl
/// Alternative strlen for all character types, with maximum length.
//***************************************************************************
template <typename T>
size_t strlen(const T* t, size_t max_length)
ETL_CONSTEXPR14 size_t strlen(const T* t, size_t max_length)
{
return etl::char_traits<T>::length(t, max_length);
}
//***************************************************************************
/// Alternative strcmp for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 int strcmp(const T* t1, const T* t2)
{
while ((*t1 != 0) || (*t2 != 0))
{
if (*t1 > *t2)
{
return 1;
}
if (*t1 < *t2)
{
return -1;
}
++t1;
++t2;
}
return 0;
}
//***************************************************************************
/// Alternative strncmp for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 int strncmp(const T* t1, const T* t2, size_t n)
{
while (((*t1 != 0) || (*t2 != 0)) && (n != 0))
{
if (*t1 < *t2)
{
return -1;
}
else if (*t1 > *t2)
{
return 1;
}
++t1;
++t2;
--n;
}
return 0;
}
//***************************************************************************
/// Alternative strcpy for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 T* strcpy(T* dst, const T* src)
{
T* result = dst;
while (*src != 0)
{
*dst++ = *src++;
}
*dst = 0;
return result;
}
//***************************************************************************
/// Alternative strncpy for all character types.
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 T* strncpy(T* dst, const T* src, size_t n)
{
T* result = dst;
while ((*src != 0) && (n != 0))
{
*dst++ = *src++;
--n;
}
*dst = 0;
return result;
}
}
#endif

View File

@ -170,7 +170,7 @@ namespace etl
size_type buffer_size;
size_type in; ///< Index to the next write.
size_type out; ///< Index to the next read.
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
//***************************************************************************
@ -933,7 +933,7 @@ namespace etl
ETL_ASSERT(!empty(), ETL_ERROR(circular_buffer_empty));
pbuffer[out].~T();
increment_out();
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -956,7 +956,7 @@ namespace etl
{
in = 0U;
out = 0U;
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
}
else
{

View File

@ -35,7 +35,6 @@ SOFTWARE.
#include "functional.h"
#include "type_traits.h"
#include <math.h>
#include <stdint.h>
namespace etl

View File

@ -42,15 +42,15 @@ SOFTWARE.
#if defined(ETL_DEBUG_COUNT)
#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count;
#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count
#define ETL_SET_DEBUG_COUNT(n) etl_debug_count.set(n)
#define ETL_GET_DEBUG_COUNT etl_debug_count.get()
#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count;
#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count;
#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n);
#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n);
#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear();
#define ETL_OBJECT_RESET_DEBUG_COUNT(object) object.etl_debug_count.clear();
#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count
#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count
#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n)
#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n)
#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear()
#define ETL_OBJECT_RESET_DEBUG_COUNT(object) object.etl_debug_count.clear()
#define ETL_OBJECT_GET_DEBUG_COUNT(object) object.etl_debug_count.get()
namespace etl
@ -62,8 +62,6 @@ namespace etl
/// Does nothing in a non-debug build.
///\ingroup reference
//***************************************************************************
class debug_count
{
public:
@ -154,23 +152,29 @@ namespace etl
};
} // namespace etl
inline void swap(etl::debug_count& lhs, etl::debug_count& rhs)
{
lhs.swap(rhs);
}
#else
#define ETL_DECLARE_DEBUG_COUNT
#define ETL_SET_DEBUG_COUNT(n)
#define ETL_GET_DEBUG_COUNT
#define ETL_INCREMENT_DEBUG_COUNT
#define ETL_DECREMENT_DEBUG_COUNT
#define ETL_ADD_DEBUG_COUNT(n)
#define ETL_SUBTRACT_DEBUG_COUNT(n)
#define ETL_RESET_DEBUG_COUNT
#define ETL_OBJECT_RESET_DEBUG_COUNT(object)
#define ETL_OBJECT_GET_DEBUG_COUNT(object)
#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count
#define ETL_SET_DEBUG_COUNT(n) ETL_DO_NOTHING
#define ETL_GET_DEBUG_COUNT ETL_DO_NOTHING
#define ETL_INCREMENT_DEBUG_COUNT ETL_DO_NOTHING
#define ETL_DECREMENT_DEBUG_COUNT ETL_DO_NOTHING
#define ETL_ADD_DEBUG_COUNT(n) ETL_DO_NOTHING
#define ETL_SUBTRACT_DEBUG_COUNT(n) ETL_DO_NOTHING
#define ETL_RESET_DEBUG_COUNT ETL_DO_NOTHING
#define ETL_OBJECT_RESET_DEBUG_COUNT(object) ETL_DO_NOTHING
#define ETL_OBJECT_GET_DEBUG_COUNT(object) ETL_DO_NOTHING
namespace etl
{
class debug_count
{
};
}
#endif // ETL_DEBUG_COUNT
#endif

View File

@ -214,7 +214,7 @@ namespace etl
size_type current_size; ///< The current number of elements in the deque.
const size_type CAPACITY; ///< The maximum number of elements in the deque.
const size_type BUFFER_SIZE; ///< The number of elements in the buffer.
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
//***************************************************************************
@ -1074,7 +1074,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -1082,7 +1082,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1141,7 +1141,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -1149,7 +1149,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1206,7 +1206,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -1214,7 +1214,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1271,7 +1271,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -1279,7 +1279,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1336,7 +1336,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -1344,7 +1344,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1751,12 +1751,29 @@ namespace etl
::new (&(*_end)) T(etl::forward<Args>(args)...);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return back();
}
#else
//*************************************************************************
/// Emplaces an item to the back of the deque.
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
reference emplace_back()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
#endif
::new (&(*_end)) T();
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT;
return back();
}
//*************************************************************************
/// Emplaces an item to the back of the deque.
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
@ -1771,7 +1788,7 @@ namespace etl
::new (&(*_end)) T(value1);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return back();
}
@ -1789,7 +1806,7 @@ namespace etl
::new (&(*_end)) T(value1, value2);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return back();
}
@ -1807,7 +1824,7 @@ namespace etl
::new (&(*_end)) T(value1, value2, value3);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return back();
}
@ -1825,7 +1842,7 @@ namespace etl
::new (&(*_end)) T(value1, value2, value3, value4);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return back();
}
#endif
@ -1884,12 +1901,29 @@ namespace etl
--_begin;
::new (&(*_begin)) T(etl::forward<Args>(args)...);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return front();
}
#else
//*************************************************************************
/// Emplaces an item to the front of the deque.
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
reference emplace_front()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
#endif
--_begin;
::new (&(*_begin)) T();
++current_size;
ETL_INCREMENT_DEBUG_COUNT;
return front();
}
//*************************************************************************
/// Emplaces an item to the front of the deque.
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
@ -1904,7 +1938,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value1);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return front();
}
@ -1922,7 +1956,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value1, value2);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return front();
}
@ -1940,7 +1974,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value1, value2, value3);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return front();
}
@ -1958,7 +1992,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value1, value2, value3, value4);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return front();
}
#endif
@ -2098,7 +2132,7 @@ namespace etl
if ETL_IF_CONSTEXPR(etl::is_trivially_destructible<T>::value)
{
current_size = 0;
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
}
else
{
@ -2137,7 +2171,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T();
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -2161,7 +2195,7 @@ namespace etl
++item;
++from;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
} while (--n != 0);
}
@ -2173,7 +2207,7 @@ namespace etl
::new (&(*_end)) T();
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -2184,7 +2218,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -2195,7 +2229,7 @@ namespace etl
::new (&(*_end)) T(value);
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
}
#if ETL_USING_CPP11
@ -2207,7 +2241,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(etl::move(value));
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -2218,7 +2252,7 @@ namespace etl
::new (&(*_end)) T(etl::move(value));
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
}
#endif
@ -2229,7 +2263,7 @@ namespace etl
{
(*_begin).~T();
--current_size;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
++_begin;
}
@ -2241,7 +2275,7 @@ namespace etl
--_end;
(*_end).~T();
--current_size;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -268,22 +268,22 @@ namespace etl
///\ingroup error_handler
//***************************************************************************
#if defined(ETL_NO_CHECKS)
#define ETL_ASSERT(b, e) // Does nothing.
#define ETL_ASSERT_OR_RETURN(b, e) // Does nothing.
#define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) // Does nothing.
#define ETL_ASSERT(b, e) ETL_DO_NOTHING // Does nothing.
#define ETL_ASSERT_OR_RETURN(b, e) ETL_DO_NOTHING // Does nothing.
#define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) ETL_DO_NOTHING // Does nothing.
#define ETL_ASSERT_FAIL(e) // Does nothing.
#define ETL_ASSERT_FAIL_AND_RETURN(e) // Does nothing.
#define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) // Does nothing.
#define ETL_ASSERT_FAIL(e) ETL_DO_NOTHING // Does nothing.
#define ETL_ASSERT_FAIL_AND_RETURN(e) ETL_DO_NOTHING // Does nothing.
#define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) ETL_DO_NOTHING // Does nothing.
#elif ETL_USING_EXCEPTIONS
#if defined(ETL_LOG_ERRORS)
#define ETL_ASSERT(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e));}} // If the condition fails, calls the error handler then throws an exception.
#define ETL_ASSERT_OR_RETURN(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return;}} // If the condition fails, calls the error handler then throws an exception.
#define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return(v);}} // If the condition fails, calls the error handler then throws an exception.
#define ETL_ASSERT_OR_RETURN(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return;}} // If the condition fails, calls the error handler then throws an exception.
#define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return(v);}} // If the condition fails, calls the error handler then throws an exception.
#define ETL_ASSERT_FAIL(e) {etl::error_handler::error((e)); throw((e));} // Calls the error handler then throws an exception.
#define ETL_ASSERT_FAIL_AND_RETURN(e) {etl::error_handler::error((e)); throw((e)); return;} // Calls the error handler then throws an exception.
#define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) {etl::error_handler::error((e)); throw((e)); return(v);} // Calls the error handler then throws an exception.
#define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) {etl::error_handler::error((e)); throw((e)); return(v);} // Calls the error handler then throws an exception.
#else
#define ETL_ASSERT(b, e) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception.
#define ETL_ASSERT_OR_RETURN(b, e) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception.
@ -297,8 +297,8 @@ namespace etl
#else
#if defined(ETL_LOG_ERRORS)
#define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}} // If the condition fails, calls the error handler
#define ETL_ASSERT_OR_RETURN(b, e) {if(!(b)) {etl::error_handler::error((e)); return;}} // If the condition fails, calls the error handler and return
#define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if(!(b)) {etl::error_handler::error((e)); return (v);}} // If the condition fails, calls the error handler and return a value
#define ETL_ASSERT_OR_RETURN(b, e) {if(!(b)) {etl::error_handler::error((e)); return;}} // If the condition fails, calls the error handler and return
#define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if(!(b)) {etl::error_handler::error((e)); return (v);}} // If the condition fails, calls the error handler and return a value
#define ETL_ASSERT_FAIL(e) {etl::error_handler::error((e));} // Calls the error handler
#define ETL_ASSERT_FAIL_AND_RETURN(e) {etl::error_handler::error((e)); return;} // Calls the error handler and return
@ -306,8 +306,8 @@ namespace etl
#else
#if ETL_IS_DEBUG_BUILD
#define ETL_ASSERT(b, e) assert((b)) // If the condition fails, asserts.
#define ETL_ASSERT_OR_RETURN(b, e) {if (!(b)) {assert(false); return;}} // If the condition fails, asserts and return.
#define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if (!(b)) {assert(false); return(v);}} // If the condition fails, asserts and return a value.
#define ETL_ASSERT_OR_RETURN(b, e) {if (!(b)) {assert(false); return;}} // If the condition fails, asserts and return.
#define ETL_ASSERT_OR_RETURN_VALUE(b, e, v) {if (!(b)) {assert(false); return(v);}} // If the condition fails, asserts and return a value.
#define ETL_ASSERT_FAIL(e) assert(false) // Asserts.
#define ETL_ASSERT_FAIL_AND_RETURN(e) {assert(false); return;} // Asserts.

View File

@ -102,5 +102,6 @@ SOFTWARE.
#define ETL_TO_ARITHMETIC_FILE_ID "69"
#define ETL_EXPECTED_FILE_ID "70"
#define ETL_ALIGNMENT_FILE_ID "71"
#define ETL_BASE64_FILE_ID "72"
#endif

View File

@ -444,7 +444,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -478,7 +478,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -510,7 +510,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -542,7 +542,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -574,7 +574,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -606,7 +606,7 @@ namespace etl
i_element->~value_type();
storage.release(etl::addressof(*i_element));
refmap_t::erase(i_element);
ETL_DECREMENT_DEBUG_COUNT;
ETL_DECREMENT_DEBUG_COUNT;;
return 1;
}
}
@ -627,7 +627,7 @@ namespace etl
i_element->~value_type();
storage.release(etl::addressof(*i_element));
refmap_t::erase(i_element);
ETL_DECREMENT_DEBUG_COUNT;
ETL_DECREMENT_DEBUG_COUNT;;
return 1;
}
}
@ -641,7 +641,7 @@ namespace etl
{
i_element->~value_type();
storage.release(etl::addressof(*i_element));
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return refmap_t::erase(i_element);
}
@ -653,7 +653,7 @@ namespace etl
{
i_element->~value_type();
storage.release(etl::addressof(*i_element));
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return refmap_t::erase(i_element);
}
@ -673,7 +673,7 @@ namespace etl
itr->~value_type();
storage.release(etl::addressof(*itr));
++itr;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
return refmap_t::erase(first, last);
@ -700,7 +700,7 @@ namespace etl
}
}
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
refmap_t::clear();
}
@ -1019,7 +1019,7 @@ namespace etl
TKeyCompare compare;
/// Internal debugging.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
#if ETL_USING_CPP11
//*************************************************************************
@ -1030,7 +1030,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(etl::forward<TValueType>(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
#else
@ -1041,7 +1041,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value_type(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
#endif
@ -1055,7 +1055,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new ((void*)etl::addressof(pvalue->first)) key_type(etl::move(key));
::new ((void*)etl::addressof(pvalue->second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -1069,7 +1069,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}

View File

@ -267,7 +267,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
return result;
@ -289,7 +289,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
return result;
@ -357,7 +357,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(mapped);
iterator i_element = upper_bound(key);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -376,7 +376,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(etl::forward<Args>(args)...);
iterator i_element = upper_bound(key);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -395,7 +395,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1);
iterator i_element = upper_bound(key);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -413,7 +413,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2);
iterator i_element = upper_bound(key);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -431,7 +431,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3);
iterator i_element = upper_bound(key);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -449,7 +449,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4);
iterator i_element = upper_bound(key);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -505,7 +505,7 @@ namespace etl
{
i_element->~value_type();
storage.release(etl::addressof(*i_element));
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return refmap_t::erase(i_element);
}
@ -517,7 +517,7 @@ namespace etl
{
i_element->~value_type();
storage.release(etl::addressof(*i_element));
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return refmap_t::erase(i_element);
}
@ -537,7 +537,7 @@ namespace etl
itr->~value_type();
storage.release(etl::addressof(*itr));
++itr;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
return refmap_t::erase(first, last);
@ -564,7 +564,7 @@ namespace etl
}
}
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
refmap_t::clear();
}
@ -881,7 +881,7 @@ namespace etl
storage_t& storage;
/// Internal debugging.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -237,7 +237,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
return result;
@ -259,7 +259,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
return result;
@ -319,7 +319,7 @@ namespace etl
//*************************************************************************
/// Emplaces a value to the set.
//*************************************************************************
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FLAT_MULTISET_FORCE_CPP03_IMPLEMENTATION)
template <typename ... Args>
ETL_OR_STD::pair<iterator, bool> emplace(Args && ... args)
{
@ -331,10 +331,27 @@ namespace etl
iterator i_element = upper_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
ETL_INCREMENT_DEBUG_COUNT;
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
#else
//*************************************************************************
/// Emplaces a value to the set.
//*************************************************************************
ETL_OR_STD::pair<iterator, bool> emplace()
{
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
// Create it.
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type();
iterator i_element = upper_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT;
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
//*************************************************************************
/// Emplaces a value to the set.
//*************************************************************************
@ -349,8 +366,8 @@ namespace etl
iterator i_element = upper_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
ETL_INCREMENT_DEBUG_COUNT;
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
//*************************************************************************
@ -367,8 +384,8 @@ namespace etl
iterator i_element = upper_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
ETL_INCREMENT_DEBUG_COUNT;
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
//*************************************************************************
@ -385,8 +402,8 @@ namespace etl
iterator i_element = upper_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
ETL_INCREMENT_DEBUG_COUNT;
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
//*************************************************************************
@ -403,8 +420,8 @@ namespace etl
iterator i_element = upper_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
ETL_INCREMENT_DEBUG_COUNT;
return ETL_OR_STD::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
#endif
@ -457,7 +474,7 @@ namespace etl
{
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return refset_t::erase(i_element);
}
@ -469,7 +486,7 @@ namespace etl
{
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return refset_t::erase(i_element);
}
@ -489,7 +506,7 @@ namespace etl
etl::destroy_at(etl::addressof(*itr));
storage.release(etl::addressof(*itr));
++itr;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
return refset_t::erase(first, last);
@ -516,7 +533,7 @@ namespace etl
}
}
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
refset_t::clear();
}
@ -835,7 +852,7 @@ namespace etl
TKeyCompare compare;
/// Internal debugging.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -240,7 +240,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
@ -266,7 +266,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
@ -326,7 +326,7 @@ namespace etl
//*************************************************************************
/// Emplaces a value to the set.
//*************************************************************************
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FLAT_SET_FORCE_CPP03_IMPLEMENTATION)
template <typename ... Args>
ETL_OR_STD::pair<iterator, bool> emplace(Args && ... args)
{
@ -343,7 +343,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(*pvalue, *i_element))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -357,6 +357,38 @@ namespace etl
return result;
}
#else
//*************************************************************************
/// Emplaces a value to the set.
//*************************************************************************
ETL_OR_STD::pair<iterator, bool> emplace()
{
ETL_ASSERT(!full(), ETL_ERROR(flat_set_full));
ETL_OR_STD::pair<iterator, bool> result;
// Create it.
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type();
iterator i_element = lower_bound(*pvalue);
// Doesn't already exist?
if ((i_element == end()) || compare(*pvalue, *i_element))
{
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
{
// Destroy it.
pvalue->~value_type();
storage.release(pvalue);
result = ETL_OR_STD::pair<iterator, bool>(end(), false);
}
return result;
}
//*************************************************************************
/// Emplaces a value to the set.
//*************************************************************************
@ -376,7 +408,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(*pvalue, *i_element))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -409,7 +441,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(*pvalue, *i_element))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -442,7 +474,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(*pvalue, *i_element))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -475,7 +507,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end()) || compare(*pvalue, *i_element))
{
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -508,7 +540,7 @@ namespace etl
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
refset_t::erase(i_element);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return 1;
}
}
@ -529,7 +561,7 @@ namespace etl
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
refset_t::erase(i_element);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return 1;
}
}
@ -543,7 +575,7 @@ namespace etl
{
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return refset_t::erase(i_element);
}
@ -555,7 +587,7 @@ namespace etl
{
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return refset_t::erase(i_element);
}
@ -575,7 +607,7 @@ namespace etl
etl::destroy_at(etl::addressof(*itr));
storage.release(etl::addressof(*itr));
++itr;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
return refset_t::erase(first, last);
@ -599,11 +631,11 @@ namespace etl
etl::destroy_at(etl::addressof(*itr));
storage.release(etl::addressof(*itr));
++itr;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
}
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
refset_t::clear();
}
@ -922,7 +954,7 @@ namespace etl
TKeyCompare compare;
/// Internal debugging.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -352,7 +352,7 @@ namespace etl
etl::ipool* p_node_pool; ///< The pool of data nodes used in the list.
size_type MAX_SIZE; ///< The maximum size of the forward_list.
bool pool_is_shared; ///< If <b>true</b> then the pool is shared between lists.
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
//***************************************************************************
@ -717,7 +717,7 @@ namespace etl
}
#endif
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FORWARD_LIST_FORCE_CPP03_IMPLEMENTATION)
//*************************************************************************
/// Emplaces a value to the front of the list..
//*************************************************************************
@ -729,11 +729,26 @@ namespace etl
#endif
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
return front();
}
#else
//*************************************************************************
/// Emplaces a value to the front of the list..
//*************************************************************************
reference emplace_front()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
#endif
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T();
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
return front();
}
//*************************************************************************
/// Emplaces a value to the front of the list..
//*************************************************************************
@ -745,7 +760,7 @@ namespace etl
#endif
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
return front();
}
@ -761,7 +776,7 @@ namespace etl
#endif
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
return front();
}
@ -777,7 +792,7 @@ namespace etl
#endif
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
return front();
}
@ -793,7 +808,7 @@ namespace etl
#endif
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
return front();
}
@ -879,7 +894,7 @@ namespace etl
return iterator(&data_node);
}
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FORWARD_LIST_FORCE_CPP03_IMPLEMENTATION)
//*************************************************************************
/// Emplaces a value to the forward_list after the specified position.
//*************************************************************************
@ -890,12 +905,27 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*to_iterator(position).p_node, *p_data_node);
return iterator(p_data_node);
}
#else
//*************************************************************************
/// Emplaces a value to the forward_list after the specified position.
//*************************************************************************
iterator emplace_after(const_iterator position)
{
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T();
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*to_iterator(position).p_node, *p_data_node);
return iterator(p_data_node);
}
//*************************************************************************
/// Emplaces a value to the forward_list after the specified position.
//*************************************************************************
@ -906,8 +936,8 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(*position.p_node, *p_data_node);
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*to_iterator(position).p_node, *p_data_node);
return iterator(p_data_node);
}
@ -922,8 +952,8 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(*position.p_node, *p_data_node);
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*to_iterator(position).p_node, *p_data_node);
return iterator(p_data_node);
}
@ -938,8 +968,8 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(*position.p_node, *p_data_node);
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*to_iterator(position).p_node, *p_data_node);
return iterator(p_data_node);
}
@ -954,8 +984,8 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(*position.p_node, *p_data_node);
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*to_iterator(position).p_node, *p_data_node);
return iterator(p_data_node);
}
@ -1432,7 +1462,7 @@ namespace etl
{
ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(forward_list_no_pool));
p_node_pool->release_all();
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
}
else
{
@ -1459,7 +1489,7 @@ namespace etl
{
data_node_t* p_node = allocate_data_node();
::new (&(p_node->value)) T(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return *p_node;
}
@ -1472,7 +1502,7 @@ namespace etl
{
data_node_t* p_node = allocate_data_node();
::new (&(p_node->value)) T(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return *p_node;
}
@ -1595,7 +1625,7 @@ namespace etl
{
node.value.~T();
p_node_pool->release(&node);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
// Disable copy construction.

View File

@ -182,6 +182,9 @@ namespace etl
// Pass this when this event also needs to be passed to the parent.
static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U;
// Pass this when this event should trigger a self transition.
static ETL_CONSTANT fsm_state_id_t Self_Transition = No_State_Change - 2U;
};
template <typename T>
@ -189,6 +192,9 @@ namespace etl
template <typename T>
ETL_CONSTANT fsm_state_id_t ifsm_state_helper<T>::Pass_To_Parent;
template <typename T>
ETL_CONSTANT fsm_state_id_t ifsm_state_helper<T>::Self_Transition;
}
//***************************************************************************
@ -204,6 +210,7 @@ namespace etl
using private_fsm::ifsm_state_helper<>::No_State_Change;
using private_fsm::ifsm_state_helper<>::Pass_To_Parent;
using private_fsm::ifsm_state_helper<>::Self_Transition;
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
template <typename, typename, etl::fsm_state_id_t, typename...>
@ -418,6 +425,11 @@ namespace etl
}
} while (p_next_state != p_state); // Have we changed state again?
}
else if (is_self_transition(next_state_id))
{
p_state->on_exit_state();
p_state->on_enter_state();
}
}
using imessage_router::accepts;
@ -504,7 +516,14 @@ namespace etl
bool have_changed_state(etl::fsm_state_id_t next_state_id) const
{
return (next_state_id != p_state->get_state_id()) &&
(next_state_id != ifsm_state::No_State_Change);
(next_state_id != ifsm_state::No_State_Change) &&
(next_state_id != ifsm_state::Self_Transition);
}
//********************************************
bool is_self_transition(etl::fsm_state_id_t next_state_id) const
{
return (next_state_id == ifsm_state::Self_Transition);
}
etl::ifsm_state* p_state; ///< A pointer to the current state.

View File

@ -201,6 +201,9 @@ namespace etl
// Pass this when this event also needs to be passed to the parent.
static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U;
// Pass this when this event should trigger a self transition.
static ETL_CONSTANT fsm_state_id_t Self_Transition = No_State_Change - 2U;
};
template <typename T>
@ -208,6 +211,9 @@ namespace etl
template <typename T>
ETL_CONSTANT fsm_state_id_t ifsm_state_helper<T>::Pass_To_Parent;
template <typename T>
ETL_CONSTANT fsm_state_id_t ifsm_state_helper<T>::Self_Transition;
}
//***************************************************************************
@ -223,6 +229,7 @@ namespace etl
using private_fsm::ifsm_state_helper<>::No_State_Change;
using private_fsm::ifsm_state_helper<>::Pass_To_Parent;
using private_fsm::ifsm_state_helper<>::Self_Transition;
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
template <typename, typename, etl::fsm_state_id_t, typename...>
@ -444,6 +451,11 @@ namespace etl
}
} while (p_next_state != p_state); // Have we changed state again?
}
else if (is_self_transition(next_state_id))
{
p_state->on_exit_state();
p_state->on_enter_state();
}
}
using imessage_router::accepts;
@ -530,7 +542,14 @@ namespace etl
bool have_changed_state(etl::fsm_state_id_t next_state_id) const
{
return (next_state_id != p_state->get_state_id()) &&
(next_state_id != ifsm_state::No_State_Change);
(next_state_id != ifsm_state::No_State_Change) &&
(next_state_id != ifsm_state::Self_Transition);
}
//********************************************
bool is_self_transition(etl::fsm_state_id_t next_state_id) const
{
return (next_state_id == ifsm_state::Self_Transition);
}
etl::ifsm_state* p_state; ///< A pointer to the current state.

View File

@ -140,7 +140,7 @@ namespace etl
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines 'value_type' which is the type of the largest parameter.")
cog.outl("/// Defines 'size' which is the size of the largest parameter.")
cog.outl("///\ingroup largest")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
@ -249,7 +249,7 @@ namespace etl
cog.outl("/// Template to determine the largest alignment.")
cog.outl("/// Supports up to %s types." % int(NTypes))
cog.outl("/// Defines <b>value</b> which is the largest alignment of all the parameters.")
cog.outl("///\ingroup largest")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):
@ -309,7 +309,7 @@ namespace etl
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
///\ingroup largest
///\\ingroup largest
//***************************************************************************
template <typename T>
struct larger_int_type
@ -407,7 +407,7 @@ namespace etl
cog.outl("/// Template to determine the largest type, size and alignment.")
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.")
cog.outl("///\ingroup largest")
cog.outl("///\\ingroup largest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):

View File

@ -63,6 +63,10 @@ cog.outl("//********************************************************************
#ifndef ETL_MESSAGE_PACKET_INCLUDED
#define ETL_MESSAGE_PACKET_INCLUDED
#include "platform.h"
#if ETL_HAS_VIRTUAL_MESSAGES
#include "message.h"
#include "error_handler.h"
#include "static_assert.h"
@ -96,17 +100,17 @@ namespace etl
public:
//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
message_packet()
: valid(false)
{
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
//********************************************
///
///
//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
template <typename T>
explicit message_packet(T&& msg)
: valid(true)
@ -138,7 +142,7 @@ namespace etl
ETL_STATIC_ASSERT(IsInMessageList<T>, "Message not in packet type list");
}
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
//**********************************************
void copy(const message_packet& other)
@ -163,7 +167,7 @@ namespace etl
}
//**********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
message_packet& operator =(const message_packet& rhs)
{
delete_current_message();
@ -175,10 +179,10 @@ namespace etl
return *this;
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
//**********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
message_packet& operator =(message_packet&& rhs)
{
delete_current_message();
@ -190,7 +194,7 @@ namespace etl
return *this;
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
//********************************************
~message_packet()
@ -267,7 +271,7 @@ namespace etl
}
//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
@ -277,7 +281,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
//********************************************
void add_new_message(const etl::imessage& msg)
@ -291,7 +295,7 @@ namespace etl
(add_new_message_type<TMessageTypes>(etl::move(msg)) || ...);
}
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
//********************************************
/// Only enabled for types that are in the typelist.
//********************************************
@ -302,9 +306,9 @@ namespace etl
void* p = data;
new (p) etl::remove_reference_t<TMessage>((etl::forward<TMessage>(msg)));
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
//********************************************
template <typename TType>
bool add_new_message_type(const etl::imessage& msg)
@ -320,7 +324,7 @@ namespace etl
return false;
}
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
//********************************************
template <typename TType>
@ -394,9 +398,9 @@ namespace etl
cog.out(" etl::is_one_of<typename etl::remove_cvref<TMessage>::type,")
for i in range(1, n):
cog.out("T%d, " % i)
cog.outl("T%s>::value);" % n)
cog.outl("T%s>::value);" % n)
cog.outl("")
cog.outl(" ETL_STATIC_ASSERT(Enabled, \"Message not in packet type list\");")
cog.outl(" ETL_STATIC_ASSERT(Enabled, \"Message not in packet type list\");")
################################################
def generate_static_assert_cpp11(n):
@ -432,15 +436,15 @@ namespace etl
cog.outl("public:")
cog.outl("")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet()")
cog.outl(" : valid(false)")
cog.outl(" {")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" explicit message_packet(const etl::imessage& msg)")
cog.outl(" {")
cog.outl(" if (accepts(msg))")
@ -455,11 +459,11 @@ namespace etl
cog.outl("")
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" explicit message_packet(etl::imessage&& msg)")
cog.outl(" {")
cog.outl(" if (accepts(msg))")
@ -474,12 +478,12 @@ namespace etl
cog.outl("")
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.out(" template <typename TMessage, typename = typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
@ -494,10 +498,10 @@ namespace etl
cog.outl(" {")
generate_static_assert_cpp11(int(Handlers))
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#else")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" template <typename TMessage>")
cog.out(" explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
for n in range(1, int(Handlers)):
@ -512,11 +516,11 @@ namespace etl
cog.outl(" {")
generate_static_assert_cpp03(int(Handlers))
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet(const message_packet& other)")
cog.outl(" : valid(other.is_valid())")
cog.outl(" {")
@ -525,11 +529,11 @@ namespace etl
cog.outl(" add_new_message(other.get());")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //**********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet(message_packet&& other)")
cog.outl(" : valid(other.is_valid())")
cog.outl(" {")
@ -538,11 +542,11 @@ namespace etl
cog.outl(" add_new_message(etl::move(other.get()));")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet& operator =(const message_packet& rhs)")
cog.outl(" {")
cog.outl(" delete_current_message();")
@ -554,11 +558,11 @@ namespace etl
cog.outl("")
cog.outl(" return *this;")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //**********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet& operator =(message_packet&& rhs)")
cog.outl(" {")
cog.outl(" delete_current_message();")
@ -570,7 +574,7 @@ namespace etl
cog.outl("")
cog.outl(" return *this;")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //********************************************")
@ -624,7 +628,7 @@ namespace etl
cog.outl(" {")
generate_accepts_return_compile_time_TMessage(int(Handlers))
cog.outl(" }")
cog.outl("")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.out(" SIZE = etl::largest<")
@ -640,7 +644,7 @@ namespace etl
cog.outl("private:")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" #include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" void delete_current_message()")
cog.outl(" {")
cog.outl(" if (valid)")
@ -650,7 +654,7 @@ namespace etl
cog.outl(" pmsg->~imessage();")
cog.outl(" }")
cog.outl(" }")
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
cog.outl(" #include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" void add_new_message(const etl::imessage& msg)")
@ -720,15 +724,15 @@ namespace etl
cog.outl("public:")
cog.outl("")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet()")
cog.outl(" : valid(false)")
cog.outl(" {")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" explicit message_packet(const etl::imessage& msg)")
cog.outl(" {")
cog.outl(" if (accepts(msg))")
@ -743,11 +747,11 @@ namespace etl
cog.outl("")
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" explicit message_packet(etl::imessage&& msg)")
cog.outl(" {")
cog.outl(" if (accepts(msg))")
@ -762,12 +766,12 @@ namespace etl
cog.outl("")
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.out(" template <typename TMessage, typename = typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
for t in range(1, n):
cog.out("T%s, " % t)
@ -782,10 +786,10 @@ namespace etl
cog.outl(" {")
generate_static_assert_cpp11(n)
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#else")
cog.outl(" //********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" template <typename TMessage>")
cog.out(" explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
for t in range(1, n):
@ -800,11 +804,11 @@ namespace etl
cog.outl(" {")
generate_static_assert_cpp03(n)
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet(const message_packet& other)")
cog.outl(" : valid(other.is_valid())")
cog.outl(" {")
@ -813,11 +817,11 @@ namespace etl
cog.outl(" add_new_message(other.get());")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //**********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet(message_packet&& other)")
cog.outl(" : valid(other.is_valid())")
cog.outl(" {")
@ -826,11 +830,11 @@ namespace etl
cog.outl(" add_new_message(etl::move(other.get()));")
cog.outl(" }")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet& operator =(const message_packet& rhs)")
cog.outl(" {")
cog.outl(" delete_current_message();")
@ -842,11 +846,11 @@ namespace etl
cog.outl("")
cog.outl(" return *this;")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
cog.outl(" //**********************************************")
cog.outl("#include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" message_packet& operator =(message_packet&& rhs)")
cog.outl(" {")
cog.outl(" delete_current_message();")
@ -858,7 +862,7 @@ namespace etl
cog.outl("")
cog.outl(" return *this;")
cog.outl(" }")
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
cog.outl("#include \"private/diagnostic_pop.h\"")
cog.outl("#endif")
cog.outl("")
cog.outl(" //********************************************")
@ -928,7 +932,7 @@ namespace etl
cog.outl("private:")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" #include \"etl/private/diagnostic_uninitialized_push.h\"")
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
cog.outl(" void delete_current_message()")
cog.outl(" {")
cog.outl(" if (valid)")
@ -938,7 +942,7 @@ namespace etl
cog.outl(" pmsg->~imessage();")
cog.outl(" }")
cog.outl(" }")
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
cog.outl(" #include \"private/diagnostic_pop.h\"")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" void add_new_message(const etl::imessage& msg)")
@ -977,5 +981,8 @@ namespace etl
/*[[[end]]]*/
#endif
}
#else
#error "etl::message_packet is not compatible with non-virtual etl::imessage"
#endif
#endif

View File

@ -66,7 +66,9 @@ cog.outl("//********************************************************************
#include "platform.h"
#include "message.h"
#include "shared_message.h"
#include "message_packet.h"
#if ETL_HAS_VIRTUAL_MESSAGES
#include "message_packet.h"
#endif
#include "message_types.h"
#include "alignment.h"
#include "error_handler.h"
@ -402,7 +404,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<TMessageTypes...> message_packet;
#endif
//**********************************************
message_router()
@ -560,10 +564,12 @@ namespace etl
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl("#if ETL_HAS_VIRTUAL_MESSAGES")
cog.out(" typedef etl::message_packet<")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
cog.outl(" T%s> message_packet;" % int(Handlers))
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::message_router_id_t id_)")
@ -728,10 +734,12 @@ namespace etl
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl("#if ETL_HAS_VIRTUAL_MESSAGES")
cog.out(" typedef etl::message_packet<")
for t in range(1, n):
cog.out("T%s, " % t)
cog.outl(" T%s> message_packet;" % n)
cog.outl("#endif")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::message_router_id_t id_)")

View File

@ -140,7 +140,7 @@ namespace etl
cog.outl("/// Supports up to %s types." % NTypes)
cog.outl("/// Defines 'value_type' which is the type of the smallest parameter.")
cog.outl("/// Defines 'size' which is the size of the smallest parameter.")
cog.outl("///\ingroup smallest")
cog.outl("///\\ingroup smallest")
cog.outl("//***************************************************************************")
cog.out("template <typename T1, ")
for n in range(2, int(NTypes)):

View File

@ -1380,7 +1380,7 @@ typedef integral_constant<bool, true> true_type;
import cog
cog.outl("//***************************************************************************")
cog.outl("/// Template to determine if a type is one of a specified list.")
cog.outl("///\ingroup types")
cog.outl("///\\ingroup types")
cog.outl("template <typename T,")
cog.out(" ")
cog.out("typename T1, ")

View File

@ -189,11 +189,18 @@ namespace etl
template<>
struct hash<wchar_t>
{
ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(wchar_t), "size_t smaller than type");
size_t operator ()(wchar_t v) const
{
return static_cast<size_t>(v);
// If it's the same size as a size_t.
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
else
{
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
return private_hash::generic_hash<size_t>(p, p + sizeof(v));
}
}
};
@ -204,11 +211,18 @@ namespace etl
template<>
struct hash<short>
{
ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(short), "size_t smaller than type");
size_t operator ()(short v) const
{
return static_cast<size_t>(v);
// If it's the same size as a size_t.
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
else
{
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
return private_hash::generic_hash<size_t>(p, p + sizeof(v));
}
}
};
@ -219,11 +233,18 @@ namespace etl
template<>
struct hash<unsigned short>
{
ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned short), "size_t smaller than type");
size_t operator ()(unsigned short v) const
{
return static_cast<size_t>(v);
// If it's the same size as a size_t.
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
else
{
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
return private_hash::generic_hash<size_t>(p, p + sizeof(v));
}
}
};
@ -234,11 +255,18 @@ namespace etl
template<>
struct hash<int>
{
ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(int), "size_t smaller than type");
size_t operator ()(int v) const
{
return static_cast<size_t>(v);
// If it's the same size as a size_t.
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
else
{
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
return private_hash::generic_hash<size_t>(p, p + sizeof(v));
}
}
};
@ -249,11 +277,18 @@ namespace etl
template<>
struct hash<unsigned int>
{
ETL_STATIC_ASSERT(sizeof(size_t) >= sizeof(unsigned int), "size_t smaller than type");
size_t operator ()(unsigned int v) const
{
return static_cast<size_t>(v);
// If it's the same size as a size_t.
if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
}
else
{
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
return private_hash::generic_hash<size_t>(p, p + sizeof(v));
}
}
};

View File

@ -598,11 +598,13 @@ namespace etl
}
//*********************************************************************
/// Does nothing.
/// For compatibility with the STL vector API.
/// Does not increase the capacity, as this is fixed.
/// Asserts an etl::vector_out_of_bounds error if the request is for more than the capacity.
//*********************************************************************
void reserve(size_t)
void reserve(size_t n)
{
ETL_ASSERT(n <= capacity(), ETL_ERROR(vector_out_of_bounds));
}
//*********************************************************************
@ -789,6 +791,18 @@ namespace etl
return back();
}
#else
//*********************************************************************
/// Constructs a value at the end of the indirect_vector.
/// If asserts or exceptions are enabled, emits vector_full if the indirect_vector is already full.
///\param value The value to add.
//*********************************************************************
reference emplace_back()
{
T* p = storage.create<T>(T());
lookup.push_back(p);
return back();
}
//*********************************************************************
/// Constructs a value at the end of the indirect_vector.
/// If asserts or exceptions are enabled, emits vector_full if the indirect_vector is already full.
@ -891,7 +905,7 @@ namespace etl
//*************************************************************************
/// Emplaces a value to the vector at the specified position.
//*************************************************************************
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_VECTOR_FORCE_CPP03_IMPLEMENTATION)
template <typename ... Args>
iterator emplace(iterator position, Args && ... args)
{
@ -903,6 +917,16 @@ namespace etl
return position;
}
#else
iterator emplace(iterator position)
{
ETL_ASSERT(!full(), ETL_ERROR(vector_full));
T* p = storage.create<T>(T());
position = iterator(lookup.insert(position.lookup_itr, p));
return position;
}
template <typename T1>
iterator emplace(iterator position, const T1& value1)
{

View File

@ -177,20 +177,16 @@ namespace etl
link_type* p_last = &start;
int count = 0;
// Add all of the elements.
while (first != last)
{
++count;
link_type& value = *first++;
link_type& value = *first++;
ETL_ASSERT_OR_RETURN(!value.is_linked(), ETL_ERROR(intrusive_forward_list_value_is_already_linked));
value.etl_next = p_last->etl_next;
value.etl_next = p_last->etl_next;
p_last->etl_next = &value;
p_last = &value;
p_last = &value;
++current_size;
}
}
@ -232,7 +228,7 @@ namespace etl
while (next != &terminator)
{
next = next->etl_next; // Point to next link.
next = next->etl_next; // Point to next link.
current->etl_next = previous; // Reverse the current link.
previous = current; // Previous points to current.
current = next; // Current points to next.

View File

@ -35,7 +35,6 @@ SOFTWARE.
#include "functional.h"
#include "limits.h"
#include <math.h>
#include <stdint.h>
namespace etl

View File

@ -377,23 +377,48 @@ namespace etl
//*************************************************************************
void release_item(char* p_value)
{
//// Does it belong to us?
//ETL_ASSERT(is_item_in_pool(p_value), ETL_ERROR(pool_object_not_in_pool));
//if (p_next != ETL_NULLPTR)
//{
// // Point it to the current free item.
// *(uintptr_t*)p_value = reinterpret_cast<uintptr_t>(p_next);
//}
//else
//{
// // This is the only free item.
// *((uintptr_t*)p_value) = 0;
//}
//p_next = p_value;
//--items_allocated;
// Does it belong to us?
ETL_ASSERT(is_item_in_pool(p_value), ETL_ERROR(pool_object_not_in_pool));
if (p_next != ETL_NULLPTR)
if (items_allocated > 0)
{
// Point it to the current free item.
*(uintptr_t*)p_value = reinterpret_cast<uintptr_t>(p_next);
if (p_next != ETL_NULLPTR)
{
// Point it to the current free item.
*(uintptr_t*)p_value = reinterpret_cast<uintptr_t>(p_next);
}
else
{
// This is the only free item.
*((uintptr_t*)p_value) = 0;
}
p_next = p_value;
--items_allocated;
}
else
else
{
// This is the only free item.
*((uintptr_t*)p_value) = 0;
ETL_ASSERT_FAIL(ETL_ERROR(pool_no_allocation));
}
p_next = p_value;
--items_allocated;
}
//*************************************************************************

View File

@ -1147,11 +1147,11 @@ namespace etl
#endif
#if ETL_NOT_USING_STL || ETL_CPP17_NOT_SUPPORTED
///**************************************************************************
//**************************************************************************
/// Get the size of a container.
/// Expects the container to have defined 'size_type'.
///\ingroup container
///**************************************************************************
//**************************************************************************
template<typename TContainer>
ETL_CONSTEXPR typename TContainer::size_type size(const TContainer& container)
{
@ -1169,13 +1169,13 @@ namespace etl
}
#endif
///**************************************************************************
//**************************************************************************
/// Get the size of an array in elements at compile time for C++03
///\code
/// sizeof(array_size(array))
///\endcode
///\ingroup container
///**************************************************************************
//**************************************************************************
template <typename T, size_t Array_Size>
char(&array_size(T(&array)[Array_Size]))[Array_Size];

View File

@ -261,7 +261,7 @@ namespace etl
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
///\ingroup largest
///\\ingroup largest
//***************************************************************************
template <typename T>
struct larger_int_type

View File

@ -36,7 +36,6 @@ SOFTWARE.
#include "type_traits.h"
#include "algorithm.h"
#include <math.h>
#include <stdint.h>
namespace etl

View File

@ -397,7 +397,7 @@ namespace etl
node_t terminal_node; ///< The node that acts as the list start and end.
size_type MAX_SIZE; ///< The maximum size of the list.
bool pool_is_shared; ///< If <b>true</b> then the pool is shared between lists.
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
//***************************************************************************
@ -857,7 +857,7 @@ namespace etl
}
#endif
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_LIST_FORCE_CPP03_IMPLEMENTATION)
//*************************************************************************
/// Emplaces a value to the front of the list.
//*************************************************************************
@ -871,11 +871,28 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
return front();
}
#else
//*************************************************************************
/// Emplaces a value to the front of the list.
//*************************************************************************
reference emplace_front()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
#endif
ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool));
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T();
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
return front();
}
//*************************************************************************
/// Emplaces a value to the front of the list.
//*************************************************************************
@ -889,7 +906,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
return front();
}
@ -907,7 +924,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
return front();
}
@ -925,7 +942,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
return front();
}
@ -943,7 +960,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
return front();
}
@ -999,11 +1016,25 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
return back();
}
#else
reference emplace_back()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
#endif
ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool));
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T();
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
return back();
}
template <typename T1>
reference emplace_back(const T1& value1)
{
@ -1014,7 +1045,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
return back();
}
@ -1029,7 +1060,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
return back();
}
@ -1044,7 +1075,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
return back();
}
@ -1059,7 +1090,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
return back();
}
@ -1108,21 +1139,34 @@ namespace etl
//*************************************************************************
/// Emplaces a value to the list at the specified position.
//*************************************************************************
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_LIST_FORCE_CPP03_IMPLEMENTATION)
template <typename ... Args>
iterator emplace(const_iterator position, Args && ... args)
iterator emplace(const_iterator position, Args&& ... args)
{
ETL_ASSERT(!full(), ETL_ERROR(list_full));
ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool));
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*to_iterator(position).p_node, *p_data_node);
return iterator(*p_data_node);
}
#else
iterator emplace(const_iterator position)
{
ETL_ASSERT(!full(), ETL_ERROR(list_full));
ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool));
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T();
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*to_iterator(position).p_node, *p_data_node);
return iterator(*p_data_node);
}
template <typename T1>
iterator emplace(const_iterator position, const T1& value1)
{
@ -1131,8 +1175,8 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1);
ETL_INCREMENT_DEBUG_COUNT
insert_node(*position.p_node, *p_data_node);
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*to_iterator(position).p_node, *p_data_node);
return iterator(*p_data_node);
}
@ -1145,8 +1189,8 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2);
ETL_INCREMENT_DEBUG_COUNT
insert_node(*position.p_node, *p_data_node);
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*to_iterator(position).p_node, *p_data_node);
return iterator(*p_data_node);
}
@ -1159,8 +1203,8 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3);
ETL_INCREMENT_DEBUG_COUNT
insert_node(*position.p_node, *p_data_node);
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*to_iterator(position).p_node, *p_data_node);
return iterator(*p_data_node);
}
@ -1173,8 +1217,8 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
ETL_INCREMENT_DEBUG_COUNT
insert_node(*position.p_node, *p_data_node);
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*to_iterator(position).p_node, *p_data_node);
return iterator(*p_data_node);
}
@ -1813,7 +1857,7 @@ namespace etl
{
ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool));
p_node_pool->release_all();
ETL_RESET_DEBUG_COUNT;
ETL_RESET_DEBUG_COUNT;;
}
else
{
@ -1955,7 +1999,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return *p_data_node;
}
@ -1970,7 +2014,7 @@ namespace etl
data_node_t* p_data_node = allocate_data_node();
::new (&(p_data_node->value)) T(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return *p_data_node;
}
@ -1993,7 +2037,7 @@ namespace etl
ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool));
node.value.~T();
p_node_pool->release(&node);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
// Disable copy construction.

View File

@ -33,13 +33,41 @@ SOFTWARE.
#define ETL_CONCAT2(X, Y) X##Y
#define ETL_CONCAT(X, Y) ETL_CONCAT2(X, Y)
#define ETL_STRINGIFY2(X) #X
#define ETL_STRINGIFY(X) ETL_STRINGIFY2(X)
#define ETL_STRING(X) ETL_CONCAT( , ETL_STRINGIFY(X))
#define ETL_WIDE_STRING(X) ETL_CONCAT( L, ETL_STRINGIFY(X))
#define ETL_STRINGIFY_1(...) #__VA_ARGS__
#define ETL_STRINGIFY(...) ETL_STRINGIFY_1(__VA_ARGS__)
#define ETL_STRING(X) ETL_CONCAT(, ETL_STRINGIFY(X))
#define ETL_WIDE_STRING(X) ETL_CONCAT(L, ETL_STRINGIFY(X))
#define ETL_U8_STRING(X) ETL_CONCAT(u8, ETL_STRINGIFY(X))
#define ETL_U16_STRING(X) ETL_CONCAT( u, ETL_STRINGIFY(X))
#define ETL_U32_STRING(X) ETL_CONCAT( U, ETL_STRINGIFY(X))
#define ETL_U16_STRING(X) ETL_CONCAT(u, ETL_STRINGIFY(X))
#define ETL_U32_STRING(X) ETL_CONCAT(U, ETL_STRINGIFY(X))
/**
* Resolves a function-like macro overload with 1 or 2 arguments.
*
* This macro can be used to call other function-like macros depending on the number of arguments
* provided by the caller.
*
* \param _1 is the first argument given to the called macro
* \param _2 is either the second argument given to the called macro
* or the name of the macro which takes two arguments
* \param SELECTED_MACRO_NAME is the name of the macro to be called
* \param ... is a non-empty list of arguments:
* The beginning of the list is a list of all macro names which accept less arguments than
* `SELECTED_MACRO_NAME`. This list may be empty.
* The last element in the list is a dummy argument. For example `""`.
* For compatibility reasons `...` should not be empty.
*
* Use this function-like macro as follows:
*
* #define TAKES1( a ) (a) //!< example macro which takes 1 argument
* #define TAKES2(a, b) (a+b) //!< example macro which takes 2 arguments
* #define TAKES_1or2(...) GET_MACRO_OVERLOAD2(__VA_ARGS__, TAKES2, TAKES1, "")(__VA_ARGS__)
*
* Now `TAKES_1or2()` can be called with 1 or 2 arguments.
*/
#define GET_MACRO_OVERLOAD2(_1, _2, SELECTED_MACRO_NAME, ...) SELECTED_MACRO_NAME
#endif

View File

@ -450,7 +450,7 @@ namespace etl
size_type current_size; ///< The number of the used nodes.
const size_type CAPACITY; ///< The maximum size of the map.
Node* root_node; ///< The node that acts as the map root.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
};
//***************************************************************************
@ -1498,7 +1498,7 @@ namespace etl
{
Data_Node& node = allocate_data_node();
::new (&node.value) value_type(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1511,7 +1511,7 @@ namespace etl
::new ((void*)etl::addressof(node.value.first)) key_type(key);
::new ((void*)etl::addressof(node.value.second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1523,7 +1523,7 @@ namespace etl
{
Data_Node& node = allocate_data_node();
::new (&node.value) value_type(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1536,7 +1536,7 @@ namespace etl
::new ((void*)etl::addressof(node.value.first)) key_type(etl::move(key));
::new ((void*)etl::addressof(node.value.second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1558,7 +1558,7 @@ namespace etl
{
node.value.~value_type();
p_node_pool->release(&node);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -35,7 +35,7 @@ SOFTWARE.
#include "functional.h"
#include "type_traits.h"
#include <math.h>
//#include <math.h>
#include <stdint.h>
namespace etl

View File

@ -1399,7 +1399,11 @@ namespace etl
pointer value = p;
p = p_;
deleter(value);
if (value != ETL_NULLPTR)
{
deleter(value);
}
}
//*********************************
@ -1605,7 +1609,11 @@ namespace etl
pointer value = p;
p = p_;
delete[] value;
if (value != ETL_NULLPTR)
{
deleter(value);
}
}
//*********************************

View File

@ -62,40 +62,127 @@ namespace etl
}
};
#if ETL_HAS_VIRTUAL_MESSAGES
//***************************************************************************
// Message interface.
/// Message interface.
/// Virtual.
//***************************************************************************
class imessage
{
public:
virtual ~imessage()
//***********************************
virtual ~imessage() ETL_NOEXCEPT
{
}
//***********************************
ETL_NODISCARD virtual etl::message_id_t get_message_id() const ETL_NOEXCEPT = 0;
};
//***************************************************************************
// Message type.
/// Message type.
/// Virtual.
//***************************************************************************
template <etl::message_id_t ID_, typename TParent = etl::imessage>
class message : public TParent
template <etl::message_id_t ID_, typename TBase = etl::imessage>
class message : public TBase
{
ETL_STATIC_ASSERT((etl::is_base_of<etl::imessage, TParent>::value), "TParent is not derived from etl::imessage");
public:
static ETL_CONSTANT etl::message_id_t ID = ID_;
ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE
//***********************************
ETL_NODISCARD virtual etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE
{
return ID;
}
//***********************************
static ETL_CONSTANT etl::message_id_t ID = ID_;
};
template <etl::message_id_t ID_, typename TParent>
ETL_CONSTANT etl::message_id_t message<ID_, TParent>::ID;
#else
//***************************************************************************
/// Message interface.
/// Non-virtual.
//***************************************************************************
class imessage
{
public:
//***********************************
ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT
{
return id;
}
protected:
//***********************************
imessage(etl::message_id_t id_) ETL_NOEXCEPT
: id(id_)
{
}
//***********************************
imessage(const imessage& other) ETL_NOEXCEPT
: id(other.id)
{
}
//***********************************
imessage& operator =(const imessage& rhs) ETL_NOEXCEPT
{
id = rhs.id;
return *this;
}
//***********************************
etl::message_id_t id;
private:
imessage() ETL_DELETE;
};
//***************************************************************************
/// Message type.
/// Non-virtual.
//***************************************************************************
template <etl::message_id_t ID_, typename TBase = etl::imessage>
class message : public TBase
{
public:
ETL_STATIC_ASSERT((etl::is_base_of<etl::imessage, TBase>::value), "TBase is not derived from etl::imessage");
//***********************************
message() ETL_NOEXCEPT
: TBase(ID)
{
}
//***********************************
message(const message&) ETL_NOEXCEPT
: TBase(ID)
{
}
//***********************************
message& operator =(const message&) ETL_NOEXCEPT
{
return *this;
}
//***********************************
static ETL_CONSTANT etl::message_id_t ID = ID_;
};
#endif
//***************************************************************************
/// The message's static ID.
//***************************************************************************
template <etl::message_id_t ID_, typename TBase>
ETL_CONSTANT etl::message_id_t etl::message<ID_, TBase>::ID;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,9 @@ SOFTWARE.
#include "platform.h"
#include "message.h"
#include "shared_message.h"
#include "message_packet.h"
#if ETL_HAS_VIRTUAL_MESSAGES
#include "message_packet.h"
#endif
#include "message_types.h"
#include "alignment.h"
#include "error_handler.h"
@ -390,7 +392,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<TMessageTypes...> message_packet;
#endif
//**********************************************
message_router()
@ -538,7 +542,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -683,7 +689,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -828,7 +836,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -972,7 +982,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -1114,7 +1126,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -1255,7 +1269,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -1395,7 +1411,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -1534,7 +1552,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8, T9> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -1671,7 +1691,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7, T8> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -1807,7 +1829,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6, T7> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -1941,7 +1965,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5, T6> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -2074,7 +2100,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4, T5> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -2205,7 +2233,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3, T4> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -2335,7 +2365,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2, T3> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -2464,7 +2496,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet<T1, T2> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)
@ -2592,7 +2626,9 @@ namespace etl
{
public:
#if ETL_HAS_VIRTUAL_MESSAGES
typedef etl::message_packet< T1> message_packet;
#endif
//**********************************************
message_router(etl::message_router_id_t id_)

View File

@ -86,7 +86,7 @@ namespace etl
: p_message(ETL_NULLPTR),
p_router(ETL_NULLPTR),
period(0),
delta(etl::timer::state::INACTIVE),
delta(etl::timer::state::Inactive),
destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS),
id(etl::timer::id::NO_TIMER),
previous(etl::timer::id::NO_TIMER),
@ -105,7 +105,7 @@ namespace etl
: p_message(&message_),
p_router(&irouter_),
period(period_),
delta(etl::timer::state::INACTIVE),
delta(etl::timer::state::Inactive),
destination_router_id(destination_router_id_),
id(id_),
previous(etl::timer::id::NO_TIMER),
@ -119,7 +119,7 @@ namespace etl
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
return delta != etl::timer::state::Inactive;
}
//*******************************************
@ -127,7 +127,7 @@ namespace etl
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
delta = etl::timer::state::Inactive;
}
const etl::imessage* p_message;
@ -271,7 +271,7 @@ namespace etl
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
timer.delta = etl::timer::state::Inactive;
}
//*******************************
@ -280,6 +280,12 @@ namespace etl
return ptimers[head];
}
//*******************************
const etl::message_timer_data& front() const
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{
@ -506,7 +512,7 @@ namespace etl
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
if (timer.period != etl::timer::state::Inactive)
{
ETL_DISABLE_TIMER_UPDATES;
if (timer.is_active())
@ -583,6 +589,18 @@ namespace etl
return false;
}
//*******************************************
/// Get the time to the next timer event.
//*******************************************
uint32_t time_to_next() const
{
ETL_DISABLE_TIMER_UPDATES;
uint32_t delta = active_list.front().delta;
ETL_ENABLE_TIMER_UPDATES;
return delta;
}
protected:
//*******************************************
@ -629,7 +647,7 @@ namespace etl
#endif
#endif
etl::timer_semaphore_t process_semaphore;
mutable etl::timer_semaphore_t process_semaphore;
#endif
uint_least8_t registered_timers;

View File

@ -225,7 +225,7 @@ namespace etl
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
if (timer.period != etl::timer::state::Inactive)
{
++process_semaphore;
if (timer.is_active())
@ -302,6 +302,18 @@ namespace etl
return false;
}
//*******************************************
/// Get the time to the next timer event.
//*******************************************
uint32_t time_to_next() const
{
++process_semaphore;
uint32_t delta = active_list.front().delta;
--process_semaphore;
return delta;
}
protected:
//*************************************************************************
@ -313,7 +325,7 @@ namespace etl
: p_message(ETL_NULLPTR)
, p_router(ETL_NULLPTR)
, period(0U)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS)
, id(etl::timer::id::NO_TIMER)
, previous(etl::timer::id::NO_TIMER)
@ -332,7 +344,7 @@ namespace etl
: p_message(&message_)
, p_router(&irouter_)
, period(period_)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, destination_router_id(destination_router_id_)
, id(id_)
, previous(etl::timer::id::NO_TIMER)
@ -346,7 +358,7 @@ namespace etl
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
return delta != etl::timer::state::Inactive;
}
//*******************************************
@ -354,7 +366,7 @@ namespace etl
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
delta = etl::timer::state::Inactive;
}
const etl::imessage* p_message;
@ -405,10 +417,10 @@ namespace etl
//*******************************
timer_list(timer_data* ptimers_)
: head(etl::timer::id::NO_TIMER),
tail(etl::timer::id::NO_TIMER),
current(etl::timer::id::NO_TIMER),
ptimers(ptimers_)
: head(etl::timer::id::NO_TIMER)
, tail(etl::timer::id::NO_TIMER)
, current(etl::timer::id::NO_TIMER)
, ptimers(ptimers_)
{
}
@ -518,7 +530,7 @@ namespace etl
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
timer.delta = etl::timer::state::Inactive;
}
//*******************************
@ -527,6 +539,12 @@ namespace etl
return ptimers[head];
}
//*******************************
const timer_data& front() const
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{
@ -581,7 +599,7 @@ namespace etl
timer_list active_list;
bool enabled;
TSemaphore process_semaphore;
mutable TSemaphore process_semaphore;
uint_least8_t registered_timers;
public:

View File

@ -232,7 +232,7 @@ namespace etl
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
if (timer.period != etl::timer::state::Inactive)
{
TInterruptGuard guard;
(void)guard; // Silence 'unused variable warnings.
@ -311,6 +311,19 @@ namespace etl
return false;
}
//*******************************************
/// Get the time to the next timer event.
//*******************************************
uint32_t time_to_next() const
{
TInterruptGuard guard;
(void)guard; // Silence 'unused variable warnings.
uint32_t delta = active_list.front().delta;
return delta;
}
protected:
//*************************************************************************
@ -322,7 +335,7 @@ namespace etl
: p_message(ETL_NULLPTR)
, p_router(ETL_NULLPTR)
, period(0)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS)
, id(etl::timer::id::NO_TIMER)
, previous(etl::timer::id::NO_TIMER)
@ -341,7 +354,7 @@ namespace etl
: p_message(&message_)
, p_router(&irouter_)
, period(period_)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, destination_router_id(destination_router_id_)
, id(id_)
, previous(etl::timer::id::NO_TIMER)
@ -355,7 +368,7 @@ namespace etl
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
return delta != etl::timer::state::Inactive;
}
//*******************************************
@ -363,7 +376,7 @@ namespace etl
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
delta = etl::timer::state::Inactive;
}
const etl::imessage* p_message;
@ -526,7 +539,7 @@ namespace etl
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
timer.delta = etl::timer::state::Inactive;
}
//*******************************
@ -535,6 +548,12 @@ namespace etl
return ptimers[head];
}
//*******************************
const timer_data& front() const
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{

View File

@ -231,7 +231,7 @@ namespace etl
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
if (timer.period != etl::timer::state::Inactive)
{
lock();
if (timer.is_active())
@ -318,6 +318,18 @@ namespace etl
unlock = unlock_;
}
//*******************************************
/// Get the time to the next timer event.
//*******************************************
uint32_t time_to_next() const
{
lock();
uint32_t delta = active_list.front().delta;
return delta;
}
protected:
//*************************************************************************
@ -329,7 +341,7 @@ namespace etl
: p_message(ETL_NULLPTR)
, p_router(ETL_NULLPTR)
, period(0)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS)
, id(etl::timer::id::NO_TIMER)
, previous(etl::timer::id::NO_TIMER)
@ -348,7 +360,7 @@ namespace etl
: p_message(&message_)
, p_router(&irouter_)
, period(period_)
, delta(etl::timer::state::INACTIVE)
, delta(etl::timer::state::Inactive)
, destination_router_id(destination_router_id_)
, id(id_)
, previous(etl::timer::id::NO_TIMER)
@ -362,7 +374,7 @@ namespace etl
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
return delta != etl::timer::state::Inactive;
}
//*******************************************
@ -370,7 +382,7 @@ namespace etl
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
delta = etl::timer::state::Inactive;
}
const etl::imessage* p_message;
@ -533,7 +545,7 @@ namespace etl
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
timer.delta = etl::timer::state::Inactive;
}
//*******************************
@ -542,6 +554,12 @@ namespace etl
return ptimers[head];
}
//*******************************
const timer_data& front() const
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{

View File

@ -134,7 +134,7 @@ namespace etl
//*************************************************************************
pointer operator ->()
{
return *p_value;
return &operator*();
}
//*************************************************************************
@ -142,7 +142,7 @@ namespace etl
//*************************************************************************
const_pointer operator ->() const
{
return *p_value;
return &operator*();
}
//*************************************************************************

View File

@ -613,7 +613,7 @@ namespace etl
size_type current_size; ///< The number of the used nodes.
const size_type CAPACITY; ///< The maximum size of the map.
Node* root_node; ///< The node that acts as the multimap root.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
};
//***************************************************************************
@ -1544,7 +1544,7 @@ namespace etl
{
Data_Node& node = allocate_data_node();
::new (&node.value) const value_type(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1556,7 +1556,7 @@ namespace etl
{
Data_Node& node = allocate_data_node();
::new (&node.value) const value_type(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
#endif
@ -1577,7 +1577,7 @@ namespace etl
{
node.value.~value_type();
p_node_pool->release(&node);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -612,7 +612,7 @@ namespace etl
size_type current_size; ///< The number of the used nodes.
const size_type CAPACITY; ///< The maximum size of the set.
Node* root_node; ///< The node that acts as the multiset root.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
};
//***************************************************************************
@ -1448,6 +1448,8 @@ namespace etl
// Skip if doing self assignment
if (this != &rhs)
{
clear();
typename etl::imultiset<TKey, TCompare>::iterator from = rhs.begin();
while (from != rhs.end())
@ -1530,7 +1532,7 @@ namespace etl
{
Data_Node& node = allocate_data_node();
::new ((void*)&node.value) value_type(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1542,7 +1544,7 @@ namespace etl
{
Data_Node& node = allocate_data_node();
::new ((void*)&node.value) value_type(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
#endif
@ -1563,7 +1565,7 @@ namespace etl
{
node.value.~value_type();
p_node_pool->release(&node);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -44,12 +44,17 @@ namespace etl
public:
mutex()
: id(0)
: id(NULL)
{
osMutexAttr_t attr = { "ETL", osMutexRecursive | osMutexPrioInherit | osMutexRobust, 0, 0 };
id = osMutexNew(&attr);
}
~mutex()
{
osMutexDelete(id);
}
void lock()
{
osMutexAcquire(id, osWaitForever);

View File

@ -115,6 +115,8 @@ namespace etl
{
public:
typedef T value_type;
//***************************************************************************
/// Constructor.
//***************************************************************************
@ -133,7 +135,7 @@ namespace etl
{
}
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
//***************************************************************************
/// Copy constructor.
//***************************************************************************
@ -145,7 +147,7 @@ namespace etl
storage.construct(other.value());
}
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
#if ETL_USING_CPP11
//***************************************************************************
@ -479,7 +481,7 @@ namespace etl
//*************************************************************************
/// Emplaces a value.
///\param args The arguments to construct with.
//*************************************************************************
//*************************************************************************
template <typename ... TArgs>
ETL_CONSTEXPR20_STL
void emplace(TArgs&& ... args)
@ -487,6 +489,24 @@ namespace etl
storage.construct(etl::forward<TArgs>(args)...);
}
#else
//*************************************************************************
/// Emplaces a value.
/// 1 parameter.
//*************************************************************************
T& emplace()
{
if (has_value())
{
// Destroy the old one.
storage.destroy();
}
T* p = ::new (&storage.u.value) T();
storage.valid = true;
return *p;
}
//*************************************************************************
/// Emplaces a value.
/// 1 parameter.
@ -566,6 +586,8 @@ namespace etl
private:
struct dummy_t {};
struct storage_type
{
//*******************************
@ -641,7 +663,7 @@ namespace etl
{
ETL_CONSTEXPR20_STL
union_type()
: dummy(0)
: dummy()
{
}
@ -650,8 +672,8 @@ namespace etl
{
}
char dummy;
T value;
dummy_t dummy;
T value;
} u;
bool valid;
@ -661,7 +683,7 @@ namespace etl
};
//*****************************************************************************
/// For POD types.
/// For arithmetic or pointer types.
///\tparam T The type to store.
///\ingroup utilities
//*****************************************************************************
@ -670,6 +692,8 @@ namespace etl
{
public:
typedef T value_type;
//***************************************************************************
/// Constructor.
//***************************************************************************
@ -713,8 +737,8 @@ namespace etl
//***************************************************************************
ETL_CONSTEXPR14 optional(const T& value_)
: valid(true)
, storage(value_)
{
storage.u.value = value_;
}
#if ETL_USING_CPP11
@ -723,8 +747,8 @@ namespace etl
//***************************************************************************
ETL_CONSTEXPR14 optional(T&& value_)
: valid(true)
, storage(etl::move(value_))
{
storage.u.value = etl::move(value_);
}
#endif
@ -744,8 +768,8 @@ namespace etl
{
if (this != &other)
{
storage.u = other.storage.u;
valid = other.valid;
storage.value = other.storage.value;
valid = other.valid;
}
return *this;
@ -759,8 +783,8 @@ namespace etl
{
if (this != &other)
{
storage.u = etl::move(other.storage.u);
valid = other.valid;
storage.value = etl::move(other.storage.value);
valid = other.valid;
}
return *this;
@ -772,7 +796,7 @@ namespace etl
//***************************************************************************
ETL_CONSTEXPR14 optional& operator =(const T& value_)
{
storage.u.value = value_;
storage.value = value_;
valid = true;
return *this;
@ -784,7 +808,7 @@ namespace etl
//***************************************************************************
ETL_CONSTEXPR14 optional& operator =(T&& value_)
{
storage.u.value = etl::move(value_);
storage.value = etl::move(value_);
valid = true;
return *this;
@ -800,7 +824,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return &storage.u.value;
return &storage.value;
}
//***************************************************************************
@ -812,7 +836,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return &storage.u.value;
return &storage.value;
}
//***************************************************************************
@ -824,7 +848,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.u.value;
return storage.value;
}
//***************************************************************************
@ -836,7 +860,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.u.value;
return storage.value;
}
#if ETL_USING_CPP11
@ -849,7 +873,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return etl::move(storage.u.value);
return etl::move(storage.value);
}
//***************************************************************************
@ -861,14 +885,14 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return etl::move(storage.u.value);
return etl::move(storage.value);
}
#endif
//***************************************************************************
/// Bool conversion operator.
//***************************************************************************
ETL_CONSTEXPR14
ETL_CONSTEXPR14
ETL_EXPLICIT operator bool() const
{
return valid;
@ -891,7 +915,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.u.value;
return storage.value;
}
//***************************************************************************
@ -903,7 +927,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.u.value;
return storage.value;
}
//***************************************************************************
@ -924,7 +948,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return etl::move(storage.u.value);
return etl::move(storage.value);
}
//***************************************************************************
@ -936,7 +960,7 @@ namespace etl
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return etl::move(storage.u.value);
return etl::move(storage.value);
}
//***************************************************************************
@ -1002,10 +1026,20 @@ namespace etl
template <typename ... Args>
ETL_CONSTEXPR14 void emplace(Args && ... args)
{
storage.u.value = T(ETL_OR_STD::forward<Args>(args)...);
storage.value = T(ETL_OR_STD::forward<Args>(args)...);
valid = true;
}
#else
//*************************************************************************
/// Emplaces a value.
/// 0 parameters.
//*************************************************************************
void emplace()
{
storage.value = value_type();
valid = true;
}
//*************************************************************************
/// Emplaces a value.
/// 1 parameter.
@ -1013,7 +1047,7 @@ namespace etl
template <typename T1>
void emplace(const T1& value1)
{
storage.u.value = value1;
storage.value = value1;
valid = true;
}
@ -1024,7 +1058,7 @@ namespace etl
template <typename T1, typename T2>
void emplace(const T1& value1, const T2& value2)
{
storage.u.value = T(value1, value2);
storage.value = T(value1, value2);
valid = true;
}
@ -1035,7 +1069,7 @@ namespace etl
template <typename T1, typename T2, typename T3>
void emplace(const T1& value1, const T2& value2, const T3& value3)
{
storage.u.value = T(value1, value2, value3);
storage.value = T(value1, value2, value3);
valid = true;
}
@ -1046,7 +1080,7 @@ namespace etl
template <typename T1, typename T2, typename T3, typename T4>
void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
storage.u.value = T(value1, value2, value3, value4);
storage.value = T(value1, value2, value3, value4);
valid = true;
}
#endif
@ -1055,30 +1089,28 @@ namespace etl
bool valid;
struct storage_type
struct dummy_t {};
union storage_type
{
storage_type()
dummy_t dummy;
T value;
ETL_CONSTEXPR storage_type()
: dummy()
{
}
union union_type
ETL_CONSTEXPR storage_type(const T& v)
: value(v)
{
union_type()
: dummy(0)
{
}
char dummy;
T value;
};
union_type u;
}
};
storage_type storage;
};
#include "etl/private/diagnostic_uninitialized_push.h"
#include "private/diagnostic_uninitialized_push.h"
//***************************************************************************
/// Equality operator. cppreference 1
@ -1372,7 +1404,7 @@ namespace etl
return rhs.has_value() ? lhs >= rhs.value() : true;
}
#include "etl/private/diagnostic_pop.h"
#include "private/diagnostic_pop.h"
//***************************************************************************
/// Make an optional.

View File

@ -35,10 +35,9 @@ SOFTWARE.
#include "utility.h"
#include "type_traits.h"
#if ETL_USING_CPP17
namespace etl
{
#if ETL_USING_CPP17
//*************************************************************************
/// Variadic template definition of overload for C++17 and above.
//*************************************************************************
@ -61,8 +60,49 @@ namespace etl
{
return overload<TOverloads...>{ etl::forward<TOverloads>(overloads)... };
}
#elif ETL_USING_CPP11
//*************************************************************************
/// Variadic template definition of overload for C++11 & C++14.
//*************************************************************************
template <typename... TRest>
struct overload;
//*************************************************************************
/// Specialisation for multiple overloads.
//*************************************************************************
template <typename TOverload, typename... TRest>
struct overload<TOverload, TRest...> : TOverload, overload<TRest...>
{
overload(TOverload first, TRest... rest) : TOverload(first), overload<TRest...>(rest...)
{
}
using TOverload::operator();
using overload<TRest...>::operator();
};
//*************************************************************************
/// Specialisation for one overload.
//*************************************************************************
template <typename TOverload>
struct overload<TOverload> : TOverload
{
overload(TOverload first) : TOverload(first)
{
}
using TOverload::operator();
};
//*************************************************************************
/// Make an overload.
//*************************************************************************
template <typename... TRest>
overload<TRest...> make_overload(TRest... overloads)
{
return overload<TRest...>(overloads...);
}
#endif
}
#endif
#endif

View File

@ -134,7 +134,7 @@ namespace etl
inline constexpr size_t parameter_pack_v = etl::parameter_pack<TTypes...>::template index_of_type<T>::value;
#endif
#if ETL_USING_CPP14
#if ETL_USING_CPP17 && (!ETL_USING_GCC_COMPILER || (__GNUC__ > 7))
//***********************************
template <typename... TTypes>
template <typename T>

View File

@ -63,6 +63,9 @@ SOFTWARE.
#include "etl_profile.h"
#endif
// Null statement
#define ETL_DO_NOTHING static_cast<void>(0)
// Determine the bit width of the platform.
#define ETL_PLATFORM_16BIT (UINT16_MAX == UINTPTR_MAX)
#define ETL_PLATFORM_32BIT (UINT32_MAX == UINTPTR_MAX)
@ -231,6 +234,14 @@ SOFTWARE.
#define ETL_HAS_MUTABLE_ARRAY_VIEW 0
#endif
//*************************************
// Indicate if etl::imassage is to be non-virtual.
#if defined(ETL_MESSAGES_ARE_NOT_VIRTUAL)
#define ETL_HAS_VIRTUAL_MESSAGES 0
#else
#define ETL_HAS_VIRTUAL_MESSAGES 1
#endif
//*************************************
// The macros below are dependent on the profile.
// C++11
@ -330,6 +341,14 @@ SOFTWARE.
#define ETL_CONSTEXPR20_STL
#endif
//*************************************
// C++23
#if ETL_USING_CPP23 && !defined(ETL_FORCE_NO_ADVANCED_CPP)
#define ETL_ASSUME(expression) [[assume(expression)]]
#else
#define ETL_ASSUME ETL_DO_NOTHING
#endif
//*************************************
// Determine if the ETL can use char8_t type.
#if ETL_USING_8BIT_TYPES
@ -449,7 +468,7 @@ namespace etl
static ETL_CONSTANT bool using_generic_compiler = (ETL_USING_GENERIC_COMPILER == 1);
static ETL_CONSTANT bool using_legacy_bitset = (ETL_USING_LEGACY_BITSET == 1);
static ETL_CONSTANT bool using_exceptions = (ETL_USING_EXCEPTIONS == 1);
// Has...
static ETL_CONSTANT bool has_initializer_list = (ETL_HAS_INITIALIZER_LIST == 1);
static ETL_CONSTANT bool has_8bit_types = (ETL_USING_8BIT_TYPES == 1);
@ -467,10 +486,10 @@ namespace etl
static ETL_CONSTANT bool has_ivector_repair = (ETL_HAS_IVECTOR_REPAIR == 1);
static ETL_CONSTANT bool has_mutable_array_view = (ETL_HAS_MUTABLE_ARRAY_VIEW == 1);
static ETL_CONSTANT bool has_ideque_repair = (ETL_HAS_IDEQUE_REPAIR == 1);
static ETL_CONSTANT bool has_virtual_messages = (ETL_HAS_VIRTUAL_MESSAGES == 1);
// Is...
static ETL_CONSTANT bool is_debug_build = (ETL_IS_DEBUG_BUILD == 1);
}
}

View File

@ -197,6 +197,22 @@ namespace etl
etl::push_heap(container.begin(), container.end(), compare);
}
#else
//*************************************************************************
/// Emplaces a value to the queue.
/// If asserts or exceptions are enabled, throws an etl::priority_queue_full
/// is the priority queue is already full.
///\param value The value to push to the queue.
//*************************************************************************
void emplace()
{
ETL_ASSERT(!full(), ETL_ERROR(etl::priority_queue_full));
// Put element at end
container.emplace_back();
// Make elements in container into heap
etl::push_heap(container.begin(), container.end(), compare);
}
//*************************************************************************
/// Emplaces a value to the queue.
/// If asserts or exceptions are enabled, throws an etl::priority_queue_full
@ -383,6 +399,7 @@ namespace etl
{
if (&rhs != this)
{
clear();
move(etl::move(rhs));
}
@ -519,6 +536,7 @@ namespace etl
{
if (&rhs != this)
{
etl::ipriority_queue<T, TContainer, TCompare>::clear();
etl::ipriority_queue<T, TContainer, TCompare>::move(etl::move(rhs));
}

View File

@ -1318,8 +1318,6 @@ namespace etl
const element_type mask = element_type(element_type(1) << position);
return (buffer & mask) != 0U;
return false;
}
//*************************************************************************
@ -3032,8 +3030,6 @@ namespace etl
const element_type mask = element_type(element_type(1) << position);
return (*pbuffer & mask) != 0U;
return false;
}
//*************************************************************************

View File

@ -33,11 +33,11 @@ SOFTWARE.
* This file is intended to evaluated multiple times by design.
*/
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
#pragma GCC diagnostic push
#if defined(__GNUC__) && (__GNUC__ >= 11) && !defined(__clang__) && !defined(__llvm__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overread"
#endif
#if defined(__clang__) || defined(__llvm__)
#pragma clang diagnostic push
#endif
#pragma clang diagnostic push
#endif

View File

@ -349,6 +349,18 @@ namespace etl
base_t::push_back(value);
}
//*********************************************************************
/// Constructs a value at the end of the vector.
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
///\param value The value to add.
//*********************************************************************
reference emplace_back()
{
base_t::emplace_back(ETL_NULLPTR);
return back();
}
//*********************************************************************
/// Constructs a value at the end of the vector.
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
@ -381,6 +393,14 @@ namespace etl
return iterator(base_t::insert(base_t::iterator(position), value));
}
//*************************************************************************
/// Emplaces a value to the vector at the specified position.
//*************************************************************************
iterator emplace(const_iterator position)
{
return iterator(base_t::emplace(base_t::iterator(position), ETL_NULLPTR));
}
//*************************************************************************
/// Emplaces a value to the vector at the specified position.
//*************************************************************************

View File

@ -462,6 +462,29 @@ namespace etl
return position_;
}
//*************************************************************************
/// Emplaces a value to the vector at the specified position.
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
//*************************************************************************
iterator emplace(const_iterator position)
{
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
iterator position_ = to_iterator(position);
if (position_ != end())
{
++p_end;
etl::copy_backward(position_, end() - 1, end());
*position_ = ETL_NULLPTR;
}
else
{
*p_end++ = ETL_NULLPTR;
}
return position_;
}
//*************************************************************************
/// Emplaces a value to the vector at the specified position.

View File

@ -460,12 +460,12 @@ namespace etl
/// Default constructor.
/// Sets the state of the instance to containing no valid data.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
variant()
: type_id(UNSUPPORTED_TYPE_ID)
{
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
//***************************************************************************
/// Constructor that catches any types that are not supported.
@ -484,7 +484,7 @@ namespace etl
/// Copy constructor.
///\param other The other variant object to copy.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
variant(const variant& other)
{
switch (other.type_id)
@ -502,7 +502,7 @@ namespace etl
type_id = other.type_id;
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_VARIANT_FORCE_CPP03_IMPLEMENTATION)
//*************************************************************************
@ -520,6 +520,21 @@ namespace etl
return *static_cast<T*>(data);
}
#else
//***************************************************************************
/// Emplace with one constructor parameter.
//***************************************************************************
template <typename T>
T& emplace()
{
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
destruct_current();
::new (static_cast<T*>(data)) T();
type_id = Type_Id_Lookup<T>::type_id;
return *static_cast<T*>(data);
}
//***************************************************************************
/// Emplace with one constructor parameter.
//***************************************************************************
@ -854,8 +869,7 @@ namespace etl
}
private:
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
//***************************************************************************
/// Destruct the current occupant of the variant.
//***************************************************************************
@ -876,7 +890,7 @@ namespace etl
type_id = UNSUPPORTED_TYPE_ID;
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
//***************************************************************************
/// The internal storage.
@ -995,4 +1009,3 @@ namespace etl
}
#endif
}

View File

@ -430,7 +430,7 @@ namespace etl
/// 'Bad variant access' exception for the variant class.
///\ingroup variant
//***************************************************************************
class bad_variant_access : public variant_exception
class bad_variant_access : public variant_exception
{
public:
bad_variant_access(string_type file_name_, numeric_type line_number_)
@ -524,7 +524,7 @@ namespace etl
/// Default constructor.
/// Sets the state of the instance to containing no valid data.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
ETL_CONSTEXPR14 variant()
{
using type = typename etl::private_variant::parameter_pack<TTypes...>::template type_from_index<0U>::type;
@ -533,12 +533,12 @@ namespace etl
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
type_id = 0U;
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
//***************************************************************************
/// Construct from a value.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
template <typename T, etl::enable_if_t<!etl::is_same<etl::remove_cvref_t<T>, variant>::value, int> = 0>
ETL_CONSTEXPR14 variant(T&& value)
: operation(operation_type<etl::remove_cvref_t<T>, etl::is_copy_constructible<etl::remove_cvref_t<T>>::value, etl::is_move_constructible<etl::remove_cvref_t<T>>::value>::do_operation)
@ -548,12 +548,12 @@ namespace etl
construct_in_place<etl::remove_cvref_t<T>>(data, etl::forward<T>(value));
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
//***************************************************************************
/// Construct from arguments.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
template <typename T, typename... TArgs>
ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t<T>, TArgs&&... args)
: operation(operation_type<etl::remove_cvref_t<T>, etl::is_copy_constructible<etl::remove_cvref_t<T>>::value, etl::is_move_constructible<etl::remove_cvref_t<T>>::value>::do_operation)
@ -563,12 +563,12 @@ namespace etl
construct_in_place_args<etl::remove_cvref_t<T>>(data, etl::forward<TArgs>(args)...);
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
//***************************************************************************
/// Construct from arguments.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
template <size_t Index, typename... TArgs>
ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t<Index>, TArgs&&... args)
: type_id(Index)
@ -580,13 +580,13 @@ namespace etl
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
#if ETL_HAS_INITIALIZER_LIST
//***************************************************************************
/// Construct from type, initializer_list and arguments.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
template <typename T, typename U, typename... TArgs >
ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t<T>, std::initializer_list<U> init, TArgs&&... args)
: operation(operation_type<etl::remove_cvref_t<T>, etl::is_copy_constructible<etl::remove_cvref_t<T>>::value, etl::is_move_constructible<etl::remove_cvref_t<T>>::value>::do_operation)
@ -596,12 +596,12 @@ namespace etl
construct_in_place_args<etl::remove_cvref_t<T>>(data, init, etl::forward<TArgs>(args)...);
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
//***************************************************************************
/// Construct from index, initializer_list and arguments.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
template <size_t Index, typename U, typename... TArgs >
ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t<Index>, std::initializer_list<U> init, TArgs&&... args)
: type_id(Index)
@ -613,14 +613,14 @@ namespace etl
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
#endif
//***************************************************************************
/// Copy constructor.
///\param other The other variant object to copy.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
ETL_CONSTEXPR14 variant(const variant& other)
: operation(other.operation)
, type_id(other.type_id)
@ -637,13 +637,13 @@ namespace etl
}
}
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
//***************************************************************************
/// Move constructor.
///\param other The other variant object to copy.
//***************************************************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "diagnostic_uninitialized_push.h"
ETL_CONSTEXPR14 variant(variant&& other)
: operation(other.operation)
, type_id(other.type_id)
@ -664,7 +664,7 @@ namespace etl
type_id = variant_npos;
}
}
#include "etl/private/diagnostic_pop.h"
#include "diagnostic_pop.h"
//***************************************************************************
/// Destructor.
@ -706,7 +706,7 @@ namespace etl
//***************************************************************************
template <size_t Index, typename... TArgs>
typename etl::variant_alternative<Index, variant<TArgs...>>::type& emplace(TArgs&&... args)
{
{
static_assert(Index < etl::private_variant::parameter_pack<TTypes...>::size, "Index out of range");
using type = typename etl::private_variant::parameter_pack<TTypes...>::template type_from_index<Index>::type;
@ -826,7 +826,7 @@ namespace etl
/// Accept an etl::visitor.
//***************************************************************************
template <typename TVisitor>
etl::enable_if_t<etl::is_visitor<TVisitor>::value, void>
etl::enable_if_t<etl::is_visitor<TVisitor>::value, void>
accept(TVisitor& v)
{
#if ETL_USING_CPP17 && !defined(ETL_VARIANT_FORCE_CPP11)
@ -840,7 +840,7 @@ namespace etl
/// Accept an etl::visitor.
//***************************************************************************
template <typename TVisitor>
etl::enable_if_t<etl::is_visitor<TVisitor>::value, void>
etl::enable_if_t<etl::is_visitor<TVisitor>::value, void>
accept(TVisitor& v) const
{
#if ETL_USING_CPP17 && !defined(ETL_VARIANT_FORCE_CPP11)
@ -1125,7 +1125,7 @@ namespace etl
{
// Workaround for MSVC (2023/05/13)
// It doesn't compile 'visitor.visit(etl::get<Index>(*this))' correctly for C++17 & C++20.
// Changed all of the instances for consistancy.
// Changed all of the instances for consistancy.
auto& v = etl::get<Index>(*this);
visitor.visit(v);
return true;
@ -1146,7 +1146,7 @@ namespace etl
{
// Workaround for MSVC (2023/05/13)
// It doesn't compile 'visitor.visit(etl::get<Index>(*this))' correctly for C++17 & C++20.
// Changed all of the instances for consistancy.
// Changed all of the instances for consistancy.
auto& v = etl::get<Index>(*this);
visitor.visit(v);
return true;
@ -1700,7 +1700,7 @@ namespace etl
struct do_visit_helper
{
using function_pointer = add_pointer_t<TRet(TCallable&&, TCurVariant&&, TVarRest&&...)>;
template <size_t tIndex>
static constexpr function_pointer fptr() noexcept
{
@ -1715,10 +1715,10 @@ namespace etl
static ETL_CONSTEXPR14 TRet do_visit(TCallable&& f, TVariant&& v, index_sequence<tIndices...>, TVarRest&&... variants)
{
ETL_ASSERT(!v.valueless_by_exception(), ETL_ERROR(bad_variant_access));
using helper_t = do_visit_helper<TRet, TCallable, TVariant, TVarRest...>;
using func_ptr = typename helper_t::function_pointer;
constexpr func_ptr jmp_table[]
{
helper_t::template fptr<tIndices>()...

View File

@ -168,7 +168,7 @@ namespace etl
#endif
const size_type CAPACITY; ///<The maximum number of elements in the vector.
ETL_DECLARE_DEBUG_COUNT ///< Internal debugging.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
}

View File

@ -31,7 +31,7 @@ SOFTWARE.
#ifndef ETL_DETERMINE_COMPILER_LANGUAGE_SUPPORT_H_INCLUDED
#define ETL_DETERMINE_COMPILER_LANGUAGE_SUPPORT_H_INCLUDED
#include <math.h>
//#include <math.h>
#include "determine_compiler.h"
@ -179,22 +179,24 @@ SOFTWARE.
#endif
// Language standard
#if ETL_USING_CPP23
#define ETL_LANGUAGE_STANDARD 23
#elif ETL_USING_CPP20
#define ETL_LANGUAGE_STANDARD 20
#elif ETL_USING_CPP17
#define ETL_LANGUAGE_STANDARD 17
#elif ETL_USING_CPP14
#define ETL_LANGUAGE_STANDARD 14
#elif ETL_USING_CPP11
#define ETL_LANGUAGE_STANDARD 11
#else
#define ETL_LANGUAGE_STANDARD 3
#if !defined(ETL_LANGUAGE_STANDARD)
#if ETL_USING_CPP23
#define ETL_LANGUAGE_STANDARD 23
#elif ETL_USING_CPP20
#define ETL_LANGUAGE_STANDARD 20
#elif ETL_USING_CPP17
#define ETL_LANGUAGE_STANDARD 17
#elif ETL_USING_CPP14
#define ETL_LANGUAGE_STANDARD 14
#elif ETL_USING_CPP11
#define ETL_LANGUAGE_STANDARD 11
#else
#define ETL_LANGUAGE_STANDARD 3
#endif
#endif
// NAN not defined or Rowley CrossWorks
#if !defined(NAN) || defined(__CROSSWORKS_ARM) || defined(ETL_COMPILER_ARM5) || defined(ARDUINO)
#if !defined(ETL_NO_CPP_NAN_SUPPORT) && (!defined(NAN) || defined(__CROSSWORKS_ARM) || defined(ETL_COMPILER_ARM5) || defined(ARDUINO))
#define ETL_NO_CPP_NAN_SUPPORT
#endif

View File

@ -35,7 +35,7 @@ SOFTWARE.
#include "functional.h"
#include "type_traits.h"
#include <math.h>
////#include <math.h>
#include <stdint.h>
namespace etl

View File

@ -193,7 +193,7 @@ namespace etl
}
++current_size;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -206,7 +206,7 @@ namespace etl
out = 0;
}
--current_size;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -217,14 +217,14 @@ namespace etl
in = 0;
out = 0;
current_size = 0;
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
}
size_type in; ///< Where to input new data.
size_type out; ///< Where to get the oldest data.
size_type current_size; ///< The number of items in the queue.
const size_type CAPACITY; ///< The maximum number of items in the queue.
ETL_DECLARE_DEBUG_COUNT ///< For internal debugging purposes.
ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes.
};
@ -349,6 +349,20 @@ namespace etl
add_in();
}
#else
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
///\param value The value to use to construct the item to push to the queue.
//*************************************************************************
void emplace()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(queue_full));
#endif
::new (&p_buffer[in]) T();
add_in();
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.

View File

@ -369,6 +369,20 @@ namespace etl
return emplace_implementation(value1, value2, value3, value4);
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
//*************************************************************************
bool emplace()
{
this->lock();
bool result = emplace_implementation();
this->unlock();
return result;
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
//*************************************************************************

View File

@ -199,6 +199,21 @@ namespace etl
return result;
}
#else
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
//*************************************************************************
bool emplace()
{
access.lock();
bool result = emplace_implementation();
access.unlock();
return result;
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
@ -470,6 +485,24 @@ namespace etl
#else
//*************************************************************************
/// Constructs a value in the queue 'in place'.
//*************************************************************************
bool emplace_implementation()
{
if (current_size != MAX_SIZE)
{
::new (&p_buffer[write_index]) T();
write_index = get_next_index(write_index, MAX_SIZE);
++current_size;
return true;
}
// Queue is full.
return false;
}
//*************************************************************************
template <typename T1>
bool emplace_implementation(const T1& value1)

View File

@ -272,6 +272,28 @@ namespace etl
return false;
}
#else
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
//*************************************************************************
bool emplace()
{
size_type write_index = write.load(etl::memory_order_relaxed);
size_type next_index = get_next_index(write_index, RESERVED);
if (next_index != read.load(etl::memory_order_acquire))
{
::new (&p_buffer[write_index]) T();
write.store(next_index, etl::memory_order_release);
return true;
}
// Queue is full.
return false;
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.

View File

@ -262,6 +262,27 @@ namespace etl
return false;
}
#else
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
//*************************************************************************
bool emplace_implementation()
{
if (current_size != MAX_SIZE)
{
::new (&p_buffer[write_index]) T();
write_index = get_next_index(write_index, MAX_SIZE);
++current_size;
return true;
}
// Queue is full.
return false;
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
@ -528,6 +549,21 @@ namespace etl
return result;
}
#else
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
//*************************************************************************
bool emplace()
{
TAccess::lock();
bool result = this->emplace_implementation();
TAccess::unlock();
return result;
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.

View File

@ -320,6 +320,21 @@ namespace etl
return emplace_implementation(value1, value2, value3, value4);
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
//*************************************************************************
bool emplace()
{
lock();
bool result = emplace_implementation();
unlock();
return result;
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
@ -640,6 +655,26 @@ namespace etl
return false;
}
#else
//*************************************************************************
/// Constructs a value in the queue 'in place'.
//*************************************************************************
bool emplace_implementation()
{
if (this->current_size != this->MAX_SIZE)
{
::new (&p_buffer[this->write_index]) T();
this->write_index = this->get_next_index(this->write_index, this->MAX_SIZE);
++this->current_size;
return true;
}
// Queue is full.
return false;
}
//*************************************************************************
/// Constructs a value in the queue 'in place'.
//*************************************************************************

View File

@ -1,4 +1,4 @@
///\file
///\file
/******************************************************************************
The MIT License(MIT)

View File

@ -36,7 +36,7 @@ SOFTWARE.
#include "type_traits.h"
#include "algorithm.h"
#include <math.h>
//#include <math.h>
#include <stdint.h>
namespace etl

View File

@ -446,7 +446,7 @@ namespace etl
size_type current_size; ///< The number of the used nodes.
const size_type CAPACITY; ///< The maximum size of the set.
Node* root_node; ///< The node that acts as the set root.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
};
@ -815,6 +815,8 @@ namespace etl
// Skip if doing self assignment
if (this != &rhs)
{
this->clear();
typename etl::iset<TKey, TCompare>::iterator from = rhs.begin();
while (from != rhs.end())
@ -1363,7 +1365,7 @@ namespace etl
{
Data_Node& node = allocate_data_node();
::new ((void*)&node.value) value_type(value);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1375,7 +1377,7 @@ namespace etl
{
Data_Node& node = allocate_data_node();
::new ((void*)&node.value) value_type(etl::move(value));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
#endif
@ -1396,7 +1398,7 @@ namespace etl
{
node.value.~value_type();
p_node_pool->release(&node);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -2603,6 +2605,8 @@ namespace etl
// Skip if doing self assignment
if (this != &rhs)
{
this->clear();
typename etl::iset<TKey, TCompare>::iterator from = rhs.begin();
while (from != rhs.end())

View File

@ -45,8 +45,8 @@ SOFTWARE.
#include "private/dynamic_extent.h"
#if ETL_USING_STL && ETL_USING_CPP11
#include <array>
#if ETL_USING_CPP20 && ETL_USING_STL
#include <span>
#endif
///\defgroup span span
@ -113,64 +113,6 @@ namespace etl
{
}
#if ETL_USING_CPP11
//*************************************************************************
/// Construct from etl::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<(N == Extent) && etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR span(etl::array<U, N>& a) ETL_NOEXCEPT
: pbegin(a.data())
{
}
//*************************************************************************
/// Construct from etl::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<(N == Extent) && etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR span(const etl::array<U, N>& a) ETL_NOEXCEPT
: pbegin(a.data())
{
}
#else
//*************************************************************************
/// 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* = 0) ETL_NOEXCEPT
: pbegin(a.data())
{
}
//*************************************************************************
/// 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* = 0) ETL_NOEXCEPT
: pbegin(a.data())
{
}
#endif
#if ETL_USING_STL && ETL_USING_CPP11
//*************************************************************************
/// Construct from std::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<(N == Extent) && etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR span(std::array<U, N>& a) ETL_NOEXCEPT
: pbegin(a.data())
{
}
//*************************************************************************
/// Construct from std::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<(N == Extent) && etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR span(const std::array<U, N>& a) ETL_NOEXCEPT
: pbegin(a.data())
{
}
#endif
#if ETL_USING_CPP11
//*************************************************************************
/// Construct from a container or other type that supports
@ -347,25 +289,6 @@ namespace etl
return pbegin[i];
}
////*************************************************************************
///// Compare two spans for equality.
////*************************************************************************
//template <typename Type2, size_t N2, typename etl::enable_if<etl::is_same<typename etl::remove_cv<Type2>::type, value_type>::value, bool>::type = true>
//ETL_NODISCARD ETL_CONSTEXPR bool operator==(const etl::span<Type2, N2>& other) const ETL_NOEXCEPT
//{
// return ((begin() == other.begin()) && (Extent == other.size())) ||
// etl::equal(begin(), end(), other.begin(), other.end());
//}
////*************************************************************************
///// Compare two spans for non-equality.
////*************************************************************************
//template <typename Type2, size_t N2, typename etl::enable_if<etl::is_same<typename etl::remove_cv<Type2>::type, value_type>::value, bool>::type = true>
//ETL_NODISCARD ETL_CONSTEXPR bool operator!=(const etl::span<Type2, N2>& other) const ETL_NOEXCEPT
//{
// return !(*this == other);
//}
//*************************************************************************
/// Obtains a span that is a view over the first COUNT elements of this span.
//*************************************************************************
@ -447,7 +370,7 @@ namespace etl
/// Span - Dynamic Extent
//***************************************************************************
template <typename T>
class span<T, etl::dynamic_extent>
class span<T, etl::dynamic_extent>
{
public:
@ -506,70 +429,6 @@ namespace etl
{
}
#if ETL_USING_CPP11
//*************************************************************************
/// Construct from etl::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR span(etl::array<U, N>& a) ETL_NOEXCEPT
: pbegin(a.data())
, pend(a.data() + a.size())
{
}
//*************************************************************************
/// Construct from etl::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR span(const etl::array<U, N>& a) ETL_NOEXCEPT
: pbegin(a.data())
, pend(a.data() + a.size())
{
}
#else
//*************************************************************************
/// 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* = 0) ETL_NOEXCEPT
: pbegin(a.data())
, pend(a.data() + a.size())
{
}
//*************************************************************************
/// 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* = 0) ETL_NOEXCEPT
: pbegin(a.data())
, pend(a.data() + a.size())
{
}
#endif
#if ETL_USING_STL && ETL_USING_CPP11
//*************************************************************************
/// Construct from std::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR span(std::array<U, N>& a) ETL_NOEXCEPT
: pbegin(a.data())
, pend(a.data() + a.size())
{
}
//*************************************************************************
/// Construct from std::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR span(const std::array<U, N>& a) ETL_NOEXCEPT
: pbegin(a.data())
, pend(a.data() + a.size())
{
}
#endif
#if ETL_USING_CPP11
//*************************************************************************
/// Construct from a container or other type that supports
@ -752,26 +611,6 @@ namespace etl
return pbegin[i];
}
////*************************************************************************
///// Compare two spans for equality.
////*************************************************************************
//template <typename Type2, typename etl::enable_if<etl::is_same<typename etl::remove_cv<Type2>::type, value_type>::value, bool>::type = true>
//ETL_NODISCARD ETL_CONSTEXPR bool operator==(const etl::span<Type2>& other) const ETL_NOEXCEPT
//{
// return (empty() && other.empty()) ||
// ((begin() == other.begin()) && (end() == other.end())) ||
// etl::equal(begin(), end(), other.begin(), other.end());
//}
////*************************************************************************
///// Compare two spans for non-equality.
////*************************************************************************
//template <typename Type2, typename etl::enable_if<etl::is_same<typename etl::remove_cv<Type2>::type, value_type>::value, bool>::type = true>
//ETL_NODISCARD ETL_CONSTEXPR bool operator!=(const etl::span<Type2>& other) const ETL_NOEXCEPT
//{
// return !(*this == other);
//}
//*************************************************************************
/// Obtains a span that is a view over the first COUNT elements of this span.
//*************************************************************************

View File

@ -176,7 +176,7 @@ namespace etl
void add_in()
{
top_index = current_size++;
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -186,7 +186,7 @@ namespace etl
{
--top_index;
--current_size;
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -196,13 +196,13 @@ namespace etl
{
top_index = 0;
current_size = 0;
ETL_RESET_DEBUG_COUNT
ETL_RESET_DEBUG_COUNT;
}
size_type top_index; ///< The index of the top of the stack.
size_type current_size; ///< The number of items in the stack.
const size_type CAPACITY; ///< The maximum number of items in the stack.
ETL_DECLARE_DEBUG_COUNT ///< For internal debugging purposes.
ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes.
};
//***************************************************************************
@ -292,6 +292,20 @@ namespace etl
::new (&p_buffer[top_index]) T(etl::forward<Args>(args)...);
}
#else
//*************************************************************************
/// Constructs a value in the stack place'.
/// If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.
///\param value The value to push to the stack.
//*************************************************************************
void emplace()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(stack_full));
#endif
base_t::add_in();
::new (&p_buffer[top_index]) T();
}
//*************************************************************************
/// Constructs a value in the stack place'.
/// If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.

View File

@ -30,9 +30,10 @@ SOFTWARE.
#define ETL_ETL_STATIC_ASSERT_INCLUDED
#include "platform.h"
#include "macros.h"
#if (ETL_USING_CPP11)
#define ETL_STATIC_ASSERT(Condition, Message) static_assert(Condition, Message)
#define ETL_STATIC_ASSERT2(Condition, Message) static_assert(Condition, Message)
#else
template <bool Condition>
struct ETL_ETL_STATIC_ASSERT_FAILED;
@ -42,11 +43,26 @@ SOFTWARE.
#define ETL_SA1(a,b) a##b
#define ETL_SA2(a,b) ETL_SA1(a,b)
#define ETL_STATIC_ASSERT(Condition, Message) \
#define ETL_STATIC_ASSERT2(Condition, Message) \
enum \
{ \
ETL_SA2(dummy, __LINE__) = sizeof(ETL_ETL_STATIC_ASSERT_FAILED<(bool)(Condition)>) \
ETL_SA2(dummy, __LINE__) = sizeof(ETL_ETL_STATIC_ASSERT_FAILED<static_cast<bool>(Condition)>) \
}
#endif
#if (ETL_USING_CPP17)
#define ETL_STATIC_ASSERT1(Condition) static_assert(Condition)
#else
#define ETL_STATIC_ASSERT1(Condition) ETL_STATIC_ASSERT2((Condition), ETL_STRINGIFY(Condition))
#endif
/**
* Overload for static_assert() with 1 or 2 arguments.
*
* Calls either STATIC_ASSERT1() or STATIC_ASSERT2().
*/
#define ETL_STATIC_ASSERT(...) \
GET_MACRO_OVERLOAD2(__VA_ARGS__, ETL_STATIC_ASSERT2, ETL_STATIC_ASSERT1, "") \
(__VA_ARGS__)
#endif

View File

@ -268,7 +268,7 @@ namespace etl
//*************************************************************************
ETL_CONSTEXPR size_t size() const
{
return (mend - mbegin);
return static_cast<size_t>(mend - mbegin);
}
//*************************************************************************

20
include/etl/stringify.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef ETL_ETL_STRINGIFY_INCLUDED
#define ETL_ETL_STRINGIFY_INCLUDED
#ifndef STRINGIFY
/** Helper macro for STRINGIFY. */
#define STRINGIFY_1(...) #__VA_ARGS__
/**
* Indirect stringification.
*
* Doing two levels allows the parameter to be a macro itself.
* For example, compile with `-DFOO=bar`, `STRINGIFY(FOO)` converts to "bar".
*
* \param x will be converted to one string, including the spaces and commas between arguments.
* For example `STRINGIFY( a , b )` will be expanded to "a , b".
*/
#define STRINGIFY(...) STRINGIFY_1(__VA_ARGS__)
#endif /* STRINGIFY */
#endif /* ETL_ETL_STRINGIFY_INCLUDED */

View File

@ -35,7 +35,7 @@ SOFTWARE.
#include "functional.h"
#include "type_traits.h"
#include <math.h>
//#include <math.h>
#include <stdint.h>
namespace etl

View File

@ -59,7 +59,10 @@ namespace etl
enum
{
SINGLE_SHOT = false,
REPEATING = true
REPEATING = true,
Single_Shot = false,
Repeating = true
};
typedef bool type;
@ -71,7 +74,10 @@ namespace etl
enum
{
DELAYED = false,
IMMEDIATE = true
IMMEDIATE = true,
Delayed = false,
Immediate = true
};
typedef bool type;
@ -82,7 +88,8 @@ namespace etl
{
enum
{
NO_TIMER = 255
NO_TIMER = 255,
No_Timer = 255
};
typedef uint_least8_t type;
@ -93,7 +100,8 @@ namespace etl
{
enum
{
INACTIVE = 0xFFFFFFFFUL
INACTIVE = 0xFFFFFFFFUL,
Inactive = 0xFFFFFFFFUL
};
};
};

View File

@ -45,6 +45,8 @@ SOFTWARE.
#include "absolute.h"
#include "expected.h"
#include <math.h>
namespace etl
{
//***************************************************************************

View File

@ -663,7 +663,7 @@ namespace etl
node.clear();
::new ((void*)etl::addressof(node.key_value_pair.first)) key_type(etl::move(key));
::new ((void*)etl::addressof(node.key_value_pair.second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
pbucket->insert_after(pbucket->before_begin(), node);
@ -707,7 +707,7 @@ namespace etl
node.clear();
::new ((void*)etl::addressof(node.key_value_pair.first)) key_type(key);
::new ((void*)etl::addressof(node.key_value_pair.second)) mapped_type();
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
pbucket->insert_after(pbucket->before_begin(), node);
@ -838,7 +838,7 @@ namespace etl
node_t& node = allocate_data_node();
node.clear();
::new ((void*)etl::addressof(node.key_value_pair)) value_type(key_value_pair);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
// Just add the pointer to the bucket;
bucket.insert_after(bucket.before_begin(), node);
@ -873,7 +873,7 @@ namespace etl
node_t& node = allocate_data_node();
node.clear();
::new ((void*)etl::addressof(node.key_value_pair)) value_type(key_value_pair);
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
// Add the node to the end of the bucket;
bucket.insert_after(inode_previous, node);
@ -916,7 +916,7 @@ namespace etl
node_t& node = allocate_data_node();
node.clear();
::new ((void*)etl::addressof(node.key_value_pair)) value_type(etl::move(key_value_pair));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
// Just add the pointer to the bucket;
bucket.insert_after(bucket.before_begin(), node);
@ -951,7 +951,7 @@ namespace etl
node_t& node = allocate_data_node();
node.clear();
::new ((void*)etl::addressof(node.key_value_pair)) value_type(etl::move(key_value_pair));
ETL_INCREMENT_DEBUG_COUNT
ETL_INCREMENT_DEBUG_COUNT;
// Add the node to the end of the bucket;
bucket.insert_after(inode_previous, node);
@ -1398,7 +1398,7 @@ namespace etl
{
// Destroy the value contents.
it->key_value_pair.~value_type();
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
++it;
}
@ -1516,7 +1516,7 @@ namespace etl
icurrent->key_value_pair.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
adjust_first_last_markers_after_erase(&bucket);
ETL_DECREMENT_DEBUG_COUNT
ETL_DECREMENT_DEBUG_COUNT;
return inext;
}
@ -1544,7 +1544,7 @@ namespace etl
key_equal key_equal_function;
/// For library debugging purposes only.
ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

Some files were not shown because too many files have changed in this diff Show More