Merge remote-tracking branch 'origin/feature/no_stl_unit_tests' into development

# Conflicts:
#	include/etl/stl/alternate/algorithm.h
#	include/etl/stl/alternate/iterator.h
#	include/etl/version.h
#	library.json
#	library.properties
#	support/Release notes.txt
#	test/test_no_stl_algorithm.cpp
#	test/test_no_stl_iterator.cpp
#	test/vs2017/etl.vcxproj
This commit is contained in:
John Wellbelove 2019-12-01 18:21:10 +00:00
parent 2591d49845
commit 5803d928a1
145 changed files with 2516 additions and 1858 deletions

View File

@ -210,6 +210,7 @@
<pMultCmdsp></pMultCmdsp> <pMultCmdsp></pMultCmdsp>
<DebugDescription> <DebugDescription>
<Enable>1</Enable> <Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>
<EnableLog>0</EnableLog> <EnableLog>0</EnableLog>
<Protocol>2</Protocol> <Protocol>2</Protocol>
<DbgClock>10000000</DbgClock> <DbgClock>10000000</DbgClock>

View File

@ -10,14 +10,14 @@
<TargetName>Target 1</TargetName> <TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber> <ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName> <ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>6090000::V6.9::.\ARMCLANG</pCCUsed> <pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
<uAC6>1</uAC6> <uAC6>0</uAC6>
<TargetOption> <TargetOption>
<TargetCommonOption> <TargetCommonOption>
<Device>STM32F401RETx</Device> <Device>STM32F401RETx</Device>
<Vendor>STMicroelectronics</Vendor> <Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32F4xx_DFP.2.13.0</PackID> <PackID>Keil.STM32F4xx_DFP.2.14.0</PackID>
<PackURL>http://www.keil.com/pack</PackURL> <PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x18000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu> <Cpu>IRAM(0x20000000,0x18000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec> <FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile> <StartupFile></StartupFile>
@ -184,6 +184,7 @@
<hadXRAM>0</hadXRAM> <hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam> <uocXRam>0</uocXRam>
<RvdsVP>2</RvdsVP> <RvdsVP>2</RvdsVP>
<RvdsMve>0</RvdsMve>
<hadIRAM2>0</hadIRAM2> <hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2> <hadIROM2>0</hadIROM2>
<StupSel>8</StupSel> <StupSel>8</StupSel>
@ -422,26 +423,26 @@
</api> </api>
</apis> </apis>
<components> <components>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.1.2" condition="ARMv6_7_8-M Device"> <component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.3.0" condition="ARMv6_7_8-M Device">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.4.0"/> <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.6.0"/>
<targetInfos> <targetInfos>
<targetInfo name="Target 1"/> <targetInfo name="Target 1"/>
</targetInfos> </targetInfos>
</component> </component>
<component Capiversion="1.00" Cbundle="NUCLEO-F401RE" Cclass="Board Support" Cgroup="Buttons" Cvendor="Keil" Cversion="1.1.0" condition="F401RE CMSIS Device"> <component Capiversion="1.0.0" Cbundle="NUCLEO-F401RE" Cclass="Board Support" Cgroup="Buttons" Cvendor="Keil" Cversion="1.1.0" condition="F401RE CMSIS Device">
<package name="STM32NUCLEO_BSP" schemaVersion="1.2" url="http://www.keil.com/pack/" vendor="Keil" version="1.6.0"/> <package name="STM32NUCLEO_BSP" schemaVersion="1.2" url="http://www.keil.com/pack/" vendor="Keil" version="1.7.0"/>
<targetInfos> <targetInfos>
<targetInfo name="Target 1"/> <targetInfo name="Target 1"/>
</targetInfos> </targetInfos>
</component> </component>
<component Capiversion="1.00" Cbundle="NUCLEO-F401RE" Cclass="Board Support" Cgroup="LED" Cvendor="Keil" Cversion="1.1.0" condition="F401RE CMSIS Device"> <component Capiversion="1.0.0" Cbundle="NUCLEO-F401RE" Cclass="Board Support" Cgroup="LED" Cvendor="Keil" Cversion="1.1.0" condition="F401RE CMSIS Device">
<package name="STM32NUCLEO_BSP" schemaVersion="1.2" url="http://www.keil.com/pack/" vendor="Keil" version="1.6.0"/> <package name="STM32NUCLEO_BSP" schemaVersion="1.2" url="http://www.keil.com/pack/" vendor="Keil" version="1.7.0"/>
<targetInfos> <targetInfos>
<targetInfo name="Target 1"/> <targetInfo name="Target 1"/>
</targetInfos> </targetInfos>
</component> </component>
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.2" condition="STM32F4 CMSIS"> <component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.3" condition="STM32F4 CMSIS">
<package name="STM32F4xx_DFP" schemaVersion="1.3" url="http://www.keil.com/pack" vendor="Keil" version="2.13.0"/> <package name="STM32F4xx_DFP" schemaVersion="1.4" url="http://www.keil.com/pack/" vendor="Keil" version="2.14.0"/>
<targetInfos> <targetInfos>
<targetInfo name="Target 1"/> <targetInfo name="Target 1"/>
</targetInfos> </targetInfos>
@ -450,16 +451,16 @@
<files> <files>
<file attr="config" category="source" condition="STM32F401xE_ARMCC" name="Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\arm\startup_stm32f401xe.s" version="2.6.0"> <file attr="config" category="source" condition="STM32F401xE_ARMCC" name="Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\arm\startup_stm32f401xe.s" version="2.6.0">
<instance index="0">RTE\Device\STM32F401RETx\startup_stm32f401xe.s</instance> <instance index="0">RTE\Device\STM32F401RETx\startup_stm32f401xe.s</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.2" condition="STM32F4 CMSIS"/> <component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.3" condition="STM32F4 CMSIS"/>
<package name="STM32F4xx_DFP" schemaVersion="1.3" url="http://www.keil.com/pack" vendor="Keil" version="2.13.0"/> <package name="STM32F4xx_DFP" schemaVersion="1.4" url="http://www.keil.com/pack/" vendor="Keil" version="2.14.0"/>
<targetInfos> <targetInfos>
<targetInfo name="Target 1"/> <targetInfo name="Target 1"/>
</targetInfos> </targetInfos>
</file> </file>
<file attr="config" category="source" name="Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c" version="2.6.0"> <file attr="config" category="source" name="Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c" version="2.6.0">
<instance index="0">RTE\Device\STM32F401RETx\system_stm32f4xx.c</instance> <instance index="0">RTE\Device\STM32F401RETx\system_stm32f4xx.c</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.2" condition="STM32F4 CMSIS"/> <component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.3" condition="STM32F4 CMSIS"/>
<package name="STM32F4xx_DFP" schemaVersion="1.3" url="http://www.keil.com/pack" vendor="Keil" version="2.13.0"/> <package name="STM32F4xx_DFP" schemaVersion="1.4" url="http://www.keil.com/pack/" vendor="Keil" version="2.14.0"/>
<targetInfos> <targetInfos>
<targetInfo name="Target 1"/> <targetInfo name="Target 1"/>
</targetInfos> </targetInfos>

View File

@ -56,7 +56,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
template <typename TIterator, template <typename TIterator,
typename TCompare> typename TCompare>
std::pair<TIterator, TIterator> minmax_element(TIterator begin, ETL_PAIR<TIterator, TIterator> minmax_element(TIterator begin,
TIterator end, TIterator end,
TCompare compare) TCompare compare)
{ {
@ -78,7 +78,7 @@ namespace etl
++begin; ++begin;
} }
return std::pair<TIterator, TIterator>(minimum, maximum); return ETL_PAIR<TIterator, TIterator>(minimum, maximum);
} }
//*************************************************************************** //***************************************************************************
@ -87,12 +87,12 @@ namespace etl
///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax_element"></a> ///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax_element"></a>
//*************************************************************************** //***************************************************************************
template <typename TIterator> template <typename TIterator>
std::pair<TIterator, TIterator> minmax_element(TIterator begin, ETL_PAIR<TIterator, TIterator> minmax_element(TIterator begin,
TIterator end) TIterator end)
{ {
typedef typename std::iterator_traits<TIterator>::value_type value_t; typedef typename ETL_STD::iterator_traits<TIterator>::value_type value_t;
return etl::minmax_element(begin, end, std::less<value_t>()); return etl::minmax_element(begin, end, ETL_STD::less<value_t>());
} }
//*************************************************************************** //***************************************************************************
@ -101,10 +101,10 @@ namespace etl
///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax"></a> ///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax"></a>
//*************************************************************************** //***************************************************************************
template <typename T> template <typename T>
std::pair<const T&, const T&> minmax(const T& a, ETL_PAIR<const T&, const T&> minmax(const T& a,
const T& b) const T& b)
{ {
return (b < a) ? std::pair<const T&, const T&>(b, a) : std::pair<const T&, const T&>(a, b); return (b < a) ? ETL_PAIR<const T&, const T&>(b, a) : ETL_PAIR<const T&, const T&>(a, b);
} }
//*************************************************************************** //***************************************************************************
@ -114,11 +114,11 @@ namespace etl
//*************************************************************************** //***************************************************************************
template <typename T, template <typename T,
typename TCompare> typename TCompare>
std::pair<const T&, const T&> minmax(const T& a, ETL_PAIR<const T&, const T&> minmax(const T& a,
const T& b, const T& b,
TCompare compare) TCompare compare)
{ {
return compare(b, a) ? std::pair<const T&, const T&>(b, a) : std::pair<const T&, const T&>(a, b); return compare(b, a) ? ETL_PAIR<const T&, const T&>(b, a) : ETL_PAIR<const T&, const T&>(a, b);
} }
//*************************************************************************** //***************************************************************************
@ -223,11 +223,11 @@ namespace etl
TOutputIterator o_begin, TOutputIterator o_begin,
TOutputIterator o_end) TOutputIterator o_end)
{ {
size_t s_size = std::distance(i_begin, i_end); size_t s_size = ETL_STD::distance(i_begin, i_end);
size_t d_size = std::distance(o_begin, o_end); size_t d_size = ETL_STD::distance(o_begin, o_end);
size_t size = (s_size < d_size) ? s_size : d_size; size_t size = (s_size < d_size) ? s_size : d_size;
return std::copy(i_begin, i_begin + size, o_begin); return ETL_STD::copy(i_begin, i_begin + size, o_begin);
} }
//*************************************************************************** //***************************************************************************
@ -271,7 +271,7 @@ namespace etl
TSize n, TSize n,
TOutputIterator o_begin) TOutputIterator o_begin)
{ {
return std::copy(i_begin, i_begin + n, o_begin); return ETL_STD::copy(i_begin, i_begin + n, o_begin);
} }
//*************************************************************************** //***************************************************************************
@ -430,7 +430,7 @@ namespace etl
TIterator end, TIterator end,
const TValue& value) const TValue& value)
{ {
TIterator it = std::lower_bound(begin, end, value); TIterator it = ETL_STD::lower_bound(begin, end, value);
if ((it == end) || (*it != value)) if ((it == end) || (*it != value))
{ {
@ -455,7 +455,7 @@ namespace etl
TBinaryPredicate predicate, TBinaryPredicate predicate,
TBinaryEquality equality) TBinaryEquality equality)
{ {
TIterator it = std::lower_bound(begin, end, value, predicate); TIterator it = ETL_STD::lower_bound(begin, end, value, predicate);
if ((it == end) || !equality(*it, value)) if ((it == end) || !equality(*it, value))
{ {
@ -514,7 +514,7 @@ namespace etl
TIterator end, TIterator end,
TUnaryPredicate predicate) TUnaryPredicate predicate)
{ {
return std::find_if(begin, end, predicate) != end; return ETL_STD::find_if(begin, end, predicate) != end;
} }
//*************************************************************************** //***************************************************************************
@ -528,7 +528,7 @@ namespace etl
TIterator end, TIterator end,
TUnaryPredicate predicate) TUnaryPredicate predicate)
{ {
return std::find_if(begin, end, predicate) == end; return ETL_STD::find_if(begin, end, predicate) == end;
} }
//*************************************************************************** //***************************************************************************
@ -546,15 +546,15 @@ namespace etl
{ {
TIterator2 end2 = begin2; TIterator2 end2 = begin2;
std::advance(end2, std::distance(begin1, end1)); ETL_STD::advance(end2, ETL_STD::distance(begin1, end1));
for (TIterator1 i = begin1; i != end1; ++i) for (TIterator1 i = begin1; i != end1; ++i)
{ {
if (i == std::find(begin1, i, *i)) if (i == ETL_STD::find(begin1, i, *i))
{ {
size_t n = std::count(begin2, end2, *i); size_t n = ETL_STD::count(begin2, end2, *i);
if (n == 0 || size_t(std::count(i, end1, *i)) != n) if (n == 0 || size_t(ETL_STD::count(i, end1, *i)) != n)
{ {
return false; return false;
} }
@ -581,11 +581,11 @@ namespace etl
{ {
for (TIterator1 i = begin1; i != end1; ++i) for (TIterator1 i = begin1; i != end1; ++i)
{ {
if (i == std::find(begin1, i, *i)) if (i == ETL_STD::find(begin1, i, *i))
{ {
size_t n = std::count(begin2, end2, *i); size_t n = ETL_STD::count(begin2, end2, *i);
if (n == 0 || size_t(std::count(i, end1, *i)) != n) if (n == 0 || size_t(ETL_STD::count(i, end1, *i)) != n)
{ {
return false; return false;
} }
@ -613,19 +613,19 @@ namespace etl
{ {
TIterator2 end2 = begin2; TIterator2 end2 = begin2;
std::advance(end2, std::distance(begin1, end1)); ETL_STD::advance(end2, ETL_STD::distance(begin1, end1));
for (TIterator1 i = begin1; i != end1; ++i) for (TIterator1 i = begin1; i != end1; ++i)
{ {
#if ETL_CPP11_SUPPORTED && !defined(ETL_NO_STL) #if ETL_CPP11_SUPPORTED && !defined(ETL_NO_STL)
if (i == std::find_if(begin1, i, std::bind(predicate, *i, std::placeholders::_1))) if (i == std::find_if(begin1, i, std::bind(predicate, *i, std::placeholders::_1)))
#else #else
if (i == std::find_if(begin1, i, std::bind1st(predicate, *i))) if (i == ETL_STD::find_if(begin1, i, ETL_STD::bind1st(predicate, *i)))
#endif #endif
{ {
size_t n = std::count(begin2, end2, *i); size_t n = ETL_STD::count(begin2, end2, *i);
if (n == 0 || size_t(std::count(i, end1, *i)) != n) if (n == 0 || size_t(ETL_STD::count(i, end1, *i)) != n)
{ {
return false; return false;
} }
@ -657,12 +657,12 @@ namespace etl
#if ETL_CPP11_SUPPORTED && !defined(ETL_NO_STL) #if ETL_CPP11_SUPPORTED && !defined(ETL_NO_STL)
if (i == std::find_if(begin1, i, std::bind(predicate, *i, std::placeholders::_1))) if (i == std::find_if(begin1, i, std::bind(predicate, *i, std::placeholders::_1)))
#else #else
if (i == std::find_if(begin1, i, std::bind1st(predicate, *i))) if (i == ETL_STD::find_if(begin1, i, ETL_STD::bind1st(predicate, *i)))
#endif #endif
{ {
size_t n = std::count(begin2, end2, *i); size_t n = ETL_STD::count(begin2, end2, *i);
if (n == 0 || size_t(std::count(i, end1, *i)) != n) if (n == 0 || size_t(ETL_STD::count(i, end1, *i)) != n)
{ {
return false; return false;
} }
@ -737,7 +737,7 @@ namespace etl
typename TDestinationTrue, typename TDestinationTrue,
typename TDestinationFalse, typename TDestinationFalse,
typename TUnaryPredicate> typename TUnaryPredicate>
std::pair<TDestinationTrue, TDestinationFalse> partition_copy(TSource begin, ETL_PAIR<TDestinationTrue, TDestinationFalse> partition_copy(TSource begin,
TSource end, TSource end,
TDestinationTrue destination_true, TDestinationTrue destination_true,
TDestinationFalse destination_false, TDestinationFalse destination_false,
@ -755,7 +755,7 @@ namespace etl
} }
} }
return std::pair<TDestinationTrue, TDestinationFalse>(destination_true, destination_false); return ETL_PAIR<TDestinationTrue, TDestinationFalse>(destination_true, destination_false);
} }
//*************************************************************************** //***************************************************************************
@ -865,7 +865,7 @@ namespace etl
TOutputIterator o_begin, TOutputIterator o_begin,
TUnaryFunction function) TUnaryFunction function)
{ {
std::transform(i_begin, i_begin + n, o_begin, function); ETL_STD::transform(i_begin, i_begin + n, o_begin, function);
} }
//*************************************************************************** //***************************************************************************
@ -887,7 +887,7 @@ namespace etl
TOutputIterator o_begin, TOutputIterator o_begin,
TBinaryFunction function) TBinaryFunction function)
{ {
std::transform(i_begin1, i_begin1 + n, i_begin2, o_begin, function); ETL_STD::transform(i_begin1, i_begin1 + n, i_begin2, o_begin, function);
} }
//*************************************************************************** //***************************************************************************
@ -1063,7 +1063,7 @@ namespace etl
template <typename TSource, typename TDestinationTrue, typename TDestinationFalse, template <typename TSource, typename TDestinationTrue, typename TDestinationFalse,
typename TUnaryFunctionTrue, typename TUnaryFunctionFalse, typename TUnaryFunctionTrue, typename TUnaryFunctionFalse,
typename TUnaryPredicate> typename TUnaryPredicate>
std::pair<TDestinationTrue, TDestinationFalse> partition_transform(TSource begin, ETL_PAIR<TDestinationTrue, TDestinationFalse> partition_transform(TSource begin,
TSource end, TSource end,
TDestinationTrue destination_true, TDestinationTrue destination_true,
TDestinationFalse destination_false, TDestinationFalse destination_false,
@ -1083,7 +1083,7 @@ namespace etl
} }
} }
return std::pair<TDestinationTrue, TDestinationFalse>(destination_true, destination_false); return ETL_PAIR<TDestinationTrue, TDestinationFalse>(destination_true, destination_false);
} }
//*************************************************************************** //***************************************************************************
@ -1098,7 +1098,7 @@ namespace etl
typename TBinaryFunctionTrue, typename TBinaryFunctionTrue,
typename TBinaryFunctionFalse, typename TBinaryFunctionFalse,
typename TBinaryPredicate> typename TBinaryPredicate>
std::pair<TDestinationTrue, TDestinationFalse> partition_transform(TSource1 begin1, ETL_PAIR<TDestinationTrue, TDestinationFalse> partition_transform(TSource1 begin1,
TSource1 end1, TSource1 end1,
TSource2 begin2, TSource2 begin2,
TDestinationTrue destination_true, TDestinationTrue destination_true,
@ -1119,7 +1119,7 @@ namespace etl
} }
} }
return std::pair<TDestinationTrue, TDestinationFalse>(destination_true, destination_false); return ETL_PAIR<TDestinationTrue, TDestinationFalse>(destination_true, destination_false);
} }
//*************************************************************************** //***************************************************************************
@ -1135,9 +1135,9 @@ namespace etl
return; return;
} }
typedef typename std::iterator_traits<TIterator>::difference_type difference_t; typedef typename ETL_STD::iterator_traits<TIterator>::difference_type difference_t;
difference_t n = std::distance(first, last); difference_t n = ETL_STD::distance(first, last);
for (difference_t i = n / 2; i > 0; i /= 2) for (difference_t i = n / 2; i > 0; i /= 2)
{ {
@ -1148,12 +1148,12 @@ namespace etl
TIterator itr1 = first; TIterator itr1 = first;
TIterator itr2 = first; TIterator itr2 = first;
std::advance(itr1, k); ETL_STD::advance(itr1, k);
std::advance(itr2, k + i); ETL_STD::advance(itr2, k + i);
if (compare(*itr2, *itr1)) if (compare(*itr2, *itr1))
{ {
std::iter_swap(itr1, itr2); ETL_STD::iter_swap(itr1, itr2);
} }
} }
} }
@ -1167,7 +1167,7 @@ namespace etl
template <typename TIterator> template <typename TIterator>
void shell_sort(TIterator first, TIterator last) void shell_sort(TIterator first, TIterator last)
{ {
etl::shell_sort(first, last, std::less<typename std::iterator_traits<TIterator>::value_type>()); etl::shell_sort(first, last, ETL_STD::less<typename ETL_STD::iterator_traits<TIterator>::value_type>());
} }
//*************************************************************************** //***************************************************************************
@ -1180,7 +1180,7 @@ namespace etl
{ {
for (TIterator itr = first; itr != last; ++itr) for (TIterator itr = first; itr != last; ++itr)
{ {
std::rotate(std::upper_bound(first, itr, *itr, compare), itr, std::next(itr)); ETL_STD::rotate(ETL_STD::upper_bound(first, itr, *itr, compare), itr, ETL_STD::next(itr));
} }
} }
@ -1191,7 +1191,7 @@ namespace etl
template <typename TIterator> template <typename TIterator>
void insertion_sort(TIterator first, TIterator last) void insertion_sort(TIterator first, TIterator last)
{ {
etl::insertion_sort(first, last, std::less<typename std::iterator_traits<TIterator>::value_type>()); etl::insertion_sort(first, last, ETL_STD::less<typename ETL_STD::iterator_traits<TIterator>::value_type>());
} }
//*************************************************************************** //***************************************************************************
@ -1212,7 +1212,7 @@ namespace etl
template <typename TIterator> template <typename TIterator>
void sort(TIterator first, TIterator last) void sort(TIterator first, TIterator last)
{ {
etl::shell_sort(first, last, std::less<typename std::iterator_traits<TIterator>::value_type>()); etl::shell_sort(first, last, ETL_STD::less<typename ETL_STD::iterator_traits<TIterator>::value_type>());
} }
//*************************************************************************** //***************************************************************************
@ -1235,7 +1235,7 @@ namespace etl
template <typename TIterator> template <typename TIterator>
void stable_sort(TIterator first, TIterator last) void stable_sort(TIterator first, TIterator last)
{ {
etl::insertion_sort(first, last, std::less<typename std::iterator_traits<TIterator>::value_type>()); etl::insertion_sort(first, last, ETL_STD::less<typename ETL_STD::iterator_traits<TIterator>::value_type>());
} }
#if ETL_CPP11_SUPPORTED #if ETL_CPP11_SUPPORTED

View File

@ -107,8 +107,8 @@ namespace etl
typedef const T* const_pointer; typedef const T* const_pointer;
typedef T* iterator; typedef T* iterator;
typedef const T* const_iterator; typedef const T* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//************************************************************************* //*************************************************************************
// Element access // Element access
@ -342,7 +342,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void fill(parameter_t value) void fill(parameter_t value)
{ {
std::fill(begin(), end(), value); ETL_STD::fill(begin(), end(), value);
} }
//************************************************************************* //*************************************************************************
@ -353,7 +353,7 @@ namespace etl
{ {
for (size_t i = 0; i < SIZE; ++i) for (size_t i = 0; i < SIZE; ++i)
{ {
std::swap(_buffer[i], other._buffer[i]); ETL_STD::swap(_buffer[i], other._buffer[i]);
} }
} }
@ -384,7 +384,7 @@ namespace etl
iterator p = etl::copy(first, last, begin(), end()); iterator p = etl::copy(first, last, begin(), end());
// Default initialise any that are left. // Default initialise any that are left.
std::fill(p, end(), value); ETL_STD::fill(p, end(), value);
} }
//************************************************************************* //*************************************************************************
@ -406,7 +406,7 @@ namespace etl
{ {
iterator p = const_cast<iterator>(position); iterator p = const_cast<iterator>(position);
std::copy_backward(p, end() - 1, end()); ETL_STD::copy_backward(p, end() - 1, end());
*p = value; *p = value;
return p; return p;
@ -436,14 +436,14 @@ namespace etl
iterator p = const_cast<iterator>(position); iterator p = const_cast<iterator>(position);
iterator result(p); iterator result(p);
size_t source_size = std::distance(first, last); size_t source_size = ETL_STD::distance(first, last);
size_t destination_space = std::distance(position, cend()); size_t destination_space = ETL_STD::distance(position, cend());
// Do we need to move anything? // Do we need to move anything?
if (source_size < destination_space) if (source_size < destination_space)
{ {
size_t length = SIZE - (std::distance(begin(), p) + source_size); size_t length = SIZE - (ETL_STD::distance(begin(), p) + source_size);
std::copy_backward(p, p + length, end()); ETL_STD::copy_backward(p, p + length, end());
} }
// Copy from the range. // Copy from the range.
@ -470,7 +470,7 @@ namespace etl
iterator erase(const_iterator position) iterator erase(const_iterator position)
{ {
iterator p = const_cast<iterator>(position); iterator p = const_cast<iterator>(position);
std::copy(p + 1, end(), p); ETL_STD::copy(p + 1, end(), p);
return p; return p;
} }
@ -495,7 +495,7 @@ namespace etl
iterator erase(const_iterator first, const_iterator last) iterator erase(const_iterator first, const_iterator last)
{ {
iterator p = const_cast<iterator>(first); iterator p = const_cast<iterator>(first);
std::copy(last, cend(), p); ETL_STD::copy(last, cend(), p);
return p; return p;
} }
@ -518,7 +518,7 @@ namespace etl
{ {
iterator p = const_cast<iterator>(position); iterator p = const_cast<iterator>(position);
std::copy(p + 1, end(), p); ETL_STD::copy(p + 1, end(), p);
back() = value; back() = value;
return p; return p;
@ -544,8 +544,8 @@ namespace etl
{ {
iterator p = const_cast<iterator>(first); iterator p = const_cast<iterator>(first);
p = std::copy(last, cend(), p); p = ETL_STD::copy(last, cend(), p);
std::fill(p, end(), value); ETL_STD::fill(p, end(), value);
return const_cast<iterator>(first); return const_cast<iterator>(first);
} }
@ -574,7 +574,7 @@ namespace etl
template <typename T, size_t SIZE> template <typename T, size_t SIZE>
bool operator ==(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs) bool operator ==(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
{ {
return std::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin()); return ETL_STD::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin());
} }
//************************************************************************* //*************************************************************************
@ -598,7 +598,7 @@ namespace etl
template <typename T, size_t SIZE> template <typename T, size_t SIZE>
bool operator <(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs) bool operator <(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
{ {
return std::lexicographical_compare(lhs.cbegin(), return ETL_STD::lexicographical_compare(lhs.cbegin(),
lhs.cend(), lhs.cend(),
rhs.cbegin(), rhs.cbegin(),
rhs.cend()); rhs.cend());

View File

@ -108,8 +108,8 @@ namespace etl
typedef const T* const_pointer; typedef const T* const_pointer;
typedef T* iterator; typedef T* iterator;
typedef const T* const_iterator; typedef const T* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//************************************************************************* //*************************************************************************
/// Default constructor. /// Default constructor.
@ -137,7 +137,7 @@ namespace etl
template <typename TIterator> template <typename TIterator>
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_)
: mbegin(etl::addressof(*begin_)), : mbegin(etl::addressof(*begin_)),
mend(etl::addressof(*begin_) + std::distance(begin_, end_)) mend(etl::addressof(*begin_) + ETL_STD::distance(begin_, end_))
{ {
} }
@ -356,7 +356,7 @@ namespace etl
void assign(const TIterator begin_, const TIterator end_) void assign(const TIterator begin_, const TIterator end_)
{ {
mbegin = etl::addressof(*begin_); mbegin = etl::addressof(*begin_);
mend = etl::addressof(*begin_) + std::distance(begin_, end_); mend = etl::addressof(*begin_) + ETL_STD::distance(begin_, end_);
} }
//************************************************************************* //*************************************************************************
@ -411,8 +411,8 @@ namespace etl
//************************************************************************* //*************************************************************************
void swap(array_view& other) void swap(array_view& other)
{ {
std::swap(mbegin, other.mbegin); ETL_STD::swap(mbegin, other.mbegin);
std::swap(mend, other.mend); ETL_STD::swap(mend, other.mend);
} }
//************************************************************************* //*************************************************************************
@ -437,7 +437,7 @@ namespace etl
friend bool operator == (const array_view<T>& lhs, const array_view<T>& rhs) friend bool operator == (const array_view<T>& lhs, const array_view<T>& rhs)
{ {
return (lhs.size() == rhs.size()) && return (lhs.size() == rhs.size()) &&
std::equal(lhs.begin(), lhs.end(), rhs.begin()); ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//************************************************************************* //*************************************************************************
@ -453,7 +453,7 @@ namespace etl
//************************************************************************* //*************************************************************************
friend bool operator < (const array_view<T>& lhs, const array_view<T>& rhs) friend bool operator < (const array_view<T>& lhs, const array_view<T>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
} }
//************************************************************************* //*************************************************************************

View File

@ -93,8 +93,8 @@ namespace etl
typedef const T* const_pointer; typedef const T* const_pointer;
typedef T* iterator; typedef T* iterator;
typedef const T* const_iterator; typedef const T* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename etl::parameter_type<T>::type parameter_t; typedef typename etl::parameter_type<T>::type parameter_t;
@ -310,7 +310,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void fill(parameter_t value) void fill(parameter_t value)
{ {
std::fill(begin(), end(), value); ETL_STD::fill(begin(), end(), value);
} }
//************************************************************************* //*************************************************************************
@ -322,7 +322,7 @@ namespace etl
{ {
for (size_t i = 0; i < SIZE; ++i) for (size_t i = 0; i < SIZE; ++i)
{ {
std::swap(ARRAY_[i], other.begin()[i]); ETL_STD::swap(ARRAY_[i], other.begin()[i]);
} }
} }
}; };
@ -334,7 +334,7 @@ namespace etl
bool operator == (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, bool operator == (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs) const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
{ {
return (SIZEL == SIZER) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (SIZEL == SIZER) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//************************************************************************* //*************************************************************************
@ -354,7 +354,7 @@ namespace etl
bool operator < (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, bool operator < (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs) const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
} }
//************************************************************************* //*************************************************************************

View File

@ -282,11 +282,11 @@ namespace etl
typedef const T* const_pointer; typedef const T* const_pointer;
typedef T* iterator; typedef T* iterator;
typedef const T* const_iterator; typedef const T* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef size_t size_type; typedef size_t size_type;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//********************************************************************* //*********************************************************************
/// Returns an iterator to the beginning of the string. /// Returns an iterator to the beginning of the string.
@ -418,12 +418,12 @@ namespace etl
is_truncated = true; is_truncated = true;
} }
new_size = std::min(new_size, CAPACITY); new_size = ETL_STD::min(new_size, CAPACITY);
// Size up? // Size up?
if (new_size > current_size) if (new_size > current_size)
{ {
std::fill(p_buffer + current_size, p_buffer + new_size, value); ETL_STD::fill(p_buffer + current_size, p_buffer + new_size, value);
} }
current_size = new_size; current_size = new_size;
@ -596,7 +596,7 @@ namespace etl
is_truncated = (length_ > CAPACITY); is_truncated = (length_ > CAPACITY);
length_ = std::min(length_, CAPACITY); length_ = ETL_STD::min(length_, CAPACITY);
etl::copy_n(other, length_, begin()); etl::copy_n(other, length_, begin());
@ -615,7 +615,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d >= 0, ETL_ERROR(string_iterator)); ETL_ASSERT(d >= 0, ETL_ERROR(string_iterator));
#endif #endif
@ -643,9 +643,9 @@ namespace etl
is_truncated = (n > CAPACITY); is_truncated = (n > CAPACITY);
n = std::min(n, CAPACITY); n = ETL_STD::min(n, CAPACITY);
std::fill_n(begin(), n, value); ETL_STD::fill_n(begin(), n, value);
current_size = n; current_size = n;
p_buffer[current_size] = 0; p_buffer[current_size] = 0;
} }
@ -780,7 +780,7 @@ namespace etl
{ {
// Insert in the middle. // Insert in the middle.
++current_size; ++current_size;
std::copy_backward(insert_position, end() - 1, end()); ETL_STD::copy_backward(insert_position, end() - 1, end());
*insert_position = value; *insert_position = value;
} }
else else
@ -796,7 +796,7 @@ namespace etl
if (position != end()) if (position != end())
{ {
// Insert in the middle. // Insert in the middle.
std::copy_backward(insert_position, end() - 1, end()); ETL_STD::copy_backward(insert_position, end() - 1, end());
*insert_position = value; *insert_position = value;
} }
@ -823,7 +823,7 @@ namespace etl
// Quick hack, as iterators are pointers. // Quick hack, as iterators are pointers.
iterator insert_position = const_cast<iterator>(position); iterator insert_position = const_cast<iterator>(position);
const size_t start = std::distance(cbegin(), position); const size_t start = ETL_STD::distance(cbegin(), position);
// No effect. // No effect.
if (start >= CAPACITY) if (start >= CAPACITY)
@ -841,7 +841,7 @@ namespace etl
} }
current_size = CAPACITY; current_size = CAPACITY;
std::fill(insert_position, end(), value); ETL_STD::fill(insert_position, end(), value);
} }
else else
{ {
@ -850,7 +850,7 @@ namespace etl
const size_t to_position = start + shift_amount; const size_t to_position = start + shift_amount;
const size_t remaining_characters = current_size - start; const size_t remaining_characters = current_size - start;
const size_t max_shift_characters = CAPACITY - start - shift_amount; const size_t max_shift_characters = CAPACITY - start - shift_amount;
const size_t characters_to_shift = std::min(max_shift_characters, remaining_characters); const size_t characters_to_shift = ETL_STD::min(max_shift_characters, remaining_characters);
// Will the string truncate? // Will the string truncate?
if ((start + shift_amount + remaining_characters) > CAPACITY) if ((start + shift_amount + remaining_characters) > CAPACITY)
@ -863,8 +863,8 @@ namespace etl
current_size += shift_amount; current_size += shift_amount;
} }
std::copy_backward(insert_position, insert_position + characters_to_shift, begin() + to_position + characters_to_shift); ETL_STD::copy_backward(insert_position, insert_position + characters_to_shift, begin() + to_position + characters_to_shift);
std::fill(insert_position, insert_position + shift_amount, value); ETL_STD::fill(insert_position, insert_position + shift_amount, value);
} }
p_buffer[current_size] = 0; p_buffer[current_size] = 0;
@ -885,8 +885,8 @@ namespace etl
return; return;
} }
const size_t start = std::distance(begin(), position); const size_t start = ETL_STD::distance(begin(), position);
const size_t n = std::distance(first, last); const size_t n = ETL_STD::distance(first, last);
// No effect. // No effect.
if (start >= CAPACITY) if (start >= CAPACITY)
@ -917,7 +917,7 @@ namespace etl
const size_t to_position = start + shift_amount; const size_t to_position = start + shift_amount;
const size_t remaining_characters = current_size - start; const size_t remaining_characters = current_size - start;
const size_t max_shift_characters = CAPACITY - start - shift_amount; const size_t max_shift_characters = CAPACITY - start - shift_amount;
const size_t characters_to_shift = std::min(max_shift_characters, remaining_characters); const size_t characters_to_shift = ETL_STD::min(max_shift_characters, remaining_characters);
// Will the string truncate? // Will the string truncate?
if ((start + shift_amount + remaining_characters) > CAPACITY) if ((start + shift_amount + remaining_characters) > CAPACITY)
@ -930,7 +930,7 @@ namespace etl
current_size += shift_amount; current_size += shift_amount;
} }
std::copy_backward(position, position + characters_to_shift, begin() + to_position + characters_to_shift); ETL_STD::copy_backward(position, position + characters_to_shift, begin() + to_position + characters_to_shift);
while (first != last) while (first != last)
{ {
@ -1037,7 +1037,7 @@ namespace etl
etl::ibasic_string<T>& erase(size_t position, size_t length_ = npos) etl::ibasic_string<T>& erase(size_t position, size_t length_ = npos)
{ {
// Limit the length. // Limit the length.
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
erase(begin() + position, begin() + position + length_); erase(begin() + position, begin() + position + length_);
@ -1051,7 +1051,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator erase(iterator i_element) iterator erase(iterator i_element)
{ {
std::copy(i_element + 1, end(), i_element); ETL_STD::copy(i_element + 1, end(), i_element);
p_buffer[--current_size] = 0; p_buffer[--current_size] = 0;
return i_element; return i_element;
@ -1067,8 +1067,8 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator erase(iterator first, iterator last) iterator erase(iterator first, iterator last)
{ {
std::copy(last, end(), first); ETL_STD::copy(last, end(), first);
size_t n_delete = std::distance(first, last); size_t n_delete = ETL_STD::distance(first, last);
current_size -= n_delete; current_size -= n_delete;
p_buffer[current_size] = 0; p_buffer[current_size] = 0;
@ -1098,7 +1098,7 @@ namespace etl
is_truncated = true; is_truncated = true;
} }
size_t endpos = std::min(pos + len, size()); size_t endpos = ETL_STD::min(pos + len, size());
for (size_t i = pos; i < endpos; ++i) for (size_t i = pos; i < endpos; ++i)
{ {
@ -1120,7 +1120,7 @@ namespace etl
return npos; return npos;
} }
const_iterator iposition = std::search(begin() + pos, end(), str.begin(), str.end()); const_iterator iposition = ETL_STD::search(begin() + pos, end(), str.begin(), str.end());
if (iposition == end()) if (iposition == end())
{ {
@ -1128,7 +1128,7 @@ namespace etl
} }
else else
{ {
return std::distance(begin(), iposition); return ETL_STD::distance(begin(), iposition);
} }
} }
@ -1146,7 +1146,7 @@ namespace etl
} }
#endif #endif
const_iterator iposition = std::search(begin() + pos, end(), s, s + etl::strlen(s)); const_iterator iposition = ETL_STD::search(begin() + pos, end(), s, s + etl::strlen(s));
if (iposition == end()) if (iposition == end())
{ {
@ -1154,7 +1154,7 @@ namespace etl
} }
else else
{ {
return std::distance(begin(), iposition); return ETL_STD::distance(begin(), iposition);
} }
} }
@ -1173,7 +1173,7 @@ namespace etl
} }
#endif #endif
const_iterator iposition = std::search(begin() + pos, end(), s, s + n); const_iterator iposition = ETL_STD::search(begin() + pos, end(), s, s + n);
if (iposition == end()) if (iposition == end())
{ {
@ -1181,7 +1181,7 @@ namespace etl
} }
else else
{ {
return std::distance(begin(), iposition); return ETL_STD::distance(begin(), iposition);
} }
} }
@ -1192,11 +1192,11 @@ namespace etl
//********************************************************************* //*********************************************************************
size_t find(T c, size_t position = 0) const size_t find(T c, size_t position = 0) const
{ {
const_iterator i = std::find(begin() + position, end(), c); const_iterator i = ETL_STD::find(begin() + position, end(), c);
if (i != end()) if (i != end())
{ {
return std::distance(begin(), i); return ETL_STD::distance(begin(), i);
} }
else else
{ {
@ -1223,7 +1223,7 @@ namespace etl
position = size() - position; position = size() - position;
const_reverse_iterator iposition = std::search(rbegin() + position, rend(), str.rbegin(), str.rend()); const_reverse_iterator iposition = ETL_STD::search(rbegin() + position, rend(), str.rbegin(), str.rend());
if (iposition == rend()) if (iposition == rend())
{ {
@ -1231,7 +1231,7 @@ namespace etl
} }
else else
{ {
return size() - str.size() - std::distance(rbegin(), iposition); return size() - str.size() - ETL_STD::distance(rbegin(), iposition);
} }
} }
@ -1259,7 +1259,7 @@ namespace etl
const_reverse_iterator srbegin(s + len); const_reverse_iterator srbegin(s + len);
const_reverse_iterator srend(s); const_reverse_iterator srend(s);
const_reverse_iterator iposition = std::search(rbegin() + position, rend(), srbegin, srend); const_reverse_iterator iposition = ETL_STD::search(rbegin() + position, rend(), srbegin, srend);
if (iposition == rend()) if (iposition == rend())
{ {
@ -1267,7 +1267,7 @@ namespace etl
} }
else else
{ {
return size() - len - std::distance(rbegin(), iposition); return size() - len - ETL_STD::distance(rbegin(), iposition);
} }
} }
@ -1293,7 +1293,7 @@ namespace etl
const_reverse_iterator srbegin(s + length_); const_reverse_iterator srbegin(s + length_);
const_reverse_iterator srend(s); const_reverse_iterator srend(s);
const_reverse_iterator iposition = std::search(rbegin() + position, rend(), srbegin, srend); const_reverse_iterator iposition = ETL_STD::search(rbegin() + position, rend(), srbegin, srend);
if (iposition == rend()) if (iposition == rend())
{ {
@ -1301,7 +1301,7 @@ namespace etl
} }
else else
{ {
return size() - length_ - std::distance(rbegin(), iposition); return size() - length_ - ETL_STD::distance(rbegin(), iposition);
} }
} }
@ -1319,11 +1319,11 @@ namespace etl
position = size() - position; position = size() - position;
const_reverse_iterator i = std::find(rbegin() + position, rend(), c); const_reverse_iterator i = ETL_STD::find(rbegin() + position, rend(), c);
if (i != rend()) if (i != rend())
{ {
return size() - std::distance(rbegin(), i) - 1; return size() - ETL_STD::distance(rbegin(), i) - 1;
} }
else else
{ {
@ -1342,7 +1342,7 @@ namespace etl
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
// Limit the length. // Limit the length.
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
// Erase the bit we want to replace. // Erase the bit we want to replace.
erase(position, length_); erase(position, length_);
@ -1388,8 +1388,8 @@ namespace etl
ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds));
// Limit the lengths. // Limit the lengths.
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
sublength = std::min(sublength, str.size() - subposition); sublength = ETL_STD::min(sublength, str.size() - subposition);
// Erase the bit we want to replace. // Erase the bit we want to replace.
erase(position, length_); erase(position, length_);
@ -1413,7 +1413,7 @@ namespace etl
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
// Limit the length. // Limit the length.
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
// Erase the bit we want to replace. // Erase the bit we want to replace.
erase(position, length_); erase(position, length_);
@ -1450,7 +1450,7 @@ namespace etl
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
// Limit the length. // Limit the length.
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
// Erase the bit we want to replace. // Erase the bit we want to replace.
erase(position, length_); erase(position, length_);
@ -1487,7 +1487,7 @@ namespace etl
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
// Limit the length. // Limit the length.
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
// Erase the bit we want to replace. // Erase the bit we want to replace.
erase(position, length_); erase(position, length_);
@ -1554,7 +1554,7 @@ namespace etl
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
// Limit the length. // Limit the length.
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
return compare(p_buffer + position, return compare(p_buffer + position,
p_buffer + position + length_, p_buffer + position + length_,
@ -1571,8 +1571,8 @@ namespace etl
ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds));
// Limit the lengths. // Limit the lengths.
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
sublength = std::min(sublength, str.size() - subposition); sublength = ETL_STD::min(sublength, str.size() - subposition);
return compare(p_buffer + position, return compare(p_buffer + position,
p_buffer + position + length_, p_buffer + position + length_,
@ -1712,7 +1712,7 @@ namespace etl
return npos; return npos;
} }
position = std::min(position, size() - 1); position = ETL_STD::min(position, size() - 1);
const_reverse_iterator it = rbegin() + size() - position - 1; const_reverse_iterator it = rbegin() + size() - position - 1;
@ -1745,7 +1745,7 @@ namespace etl
return npos; return npos;
} }
position = std::min(position, size() - 1); position = ETL_STD::min(position, size() - 1);
const_reverse_iterator it = rbegin() + size() - position - 1; const_reverse_iterator it = rbegin() + size() - position - 1;
@ -1869,7 +1869,7 @@ namespace etl
return npos; return npos;
} }
position = std::min(position, size() - 1); position = ETL_STD::min(position, size() - 1);
const_reverse_iterator it = rbegin() + size() - position - 1; const_reverse_iterator it = rbegin() + size() - position - 1;
@ -1907,7 +1907,7 @@ namespace etl
return npos; return npos;
} }
position = std::min(position, size() - 1); position = ETL_STD::min(position, size() - 1);
const_reverse_iterator it = rbegin() + size() - position - 1; const_reverse_iterator it = rbegin() + size() - position - 1;
@ -2106,7 +2106,7 @@ namespace etl
template <typename T> template <typename T>
bool operator ==(const etl::ibasic_string<T>& lhs, const etl::ibasic_string<T>& rhs) bool operator ==(const etl::ibasic_string<T>& lhs, const etl::ibasic_string<T>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -2119,7 +2119,7 @@ namespace etl
template <typename T> template <typename T>
bool operator ==(const etl::ibasic_string<T>& lhs, const T* rhs) bool operator ==(const etl::ibasic_string<T>& lhs, const T* rhs)
{ {
return (lhs.size() == etl::strlen(rhs)) && std::equal(lhs.begin(), lhs.end(), rhs); return (lhs.size() == etl::strlen(rhs)) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs);
} }
//*************************************************************************** //***************************************************************************
@ -2132,7 +2132,7 @@ namespace etl
template <typename T> template <typename T>
bool operator ==(const T* lhs, const etl::ibasic_string<T>& rhs) bool operator ==(const T* lhs, const etl::ibasic_string<T>& rhs)
{ {
return (rhs.size() == etl::strlen(lhs)) && std::equal(rhs.begin(), rhs.end(), lhs); return (rhs.size() == etl::strlen(lhs)) && ETL_STD::equal(rhs.begin(), rhs.end(), lhs);
} }
@ -2186,7 +2186,7 @@ namespace etl
template <typename T> template <typename T>
bool operator <(const etl::ibasic_string<T>& lhs, const etl::ibasic_string<T>& rhs) bool operator <(const etl::ibasic_string<T>& lhs, const etl::ibasic_string<T>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
} }
//*************************************************************************** //***************************************************************************
@ -2199,7 +2199,7 @@ namespace etl
template <typename T> template <typename T>
bool operator <(const etl::ibasic_string<T>& lhs, const T* rhs) bool operator <(const etl::ibasic_string<T>& lhs, const T* rhs)
{ {
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs, rhs + etl::strlen(rhs)); return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs, rhs + etl::strlen(rhs));
} }
//*************************************************************************** //***************************************************************************
@ -2212,7 +2212,7 @@ namespace etl
template <typename T> template <typename T>
bool operator <(const T* lhs, const etl::ibasic_string<T>& rhs) bool operator <(const T* lhs, const etl::ibasic_string<T>& rhs)
{ {
return std::lexicographical_compare(lhs, lhs + etl::strlen(lhs), rhs.begin(), rhs.end()); return ETL_STD::lexicographical_compare(lhs, lhs + etl::strlen(lhs), rhs.begin(), rhs.end());
} }

View File

@ -238,7 +238,7 @@ namespace etl
ETL_STATIC_ASSERT(etl::is_integral<TValue>::value, "TValue not an integral type"); ETL_STATIC_ASSERT(etl::is_integral<TValue>::value, "TValue not an integral type");
ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type"); ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type");
ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type"); ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type");
ETL_STATIC_ASSERT(NBITS <= std::numeric_limits<TReturn>::digits, "NBITS too large for return type"); ETL_STATIC_ASSERT(NBITS <= ETL_STD::numeric_limits<TReturn>::digits, "NBITS too large for return type");
struct S struct S
{ {
@ -260,8 +260,8 @@ namespace etl
ETL_STATIC_ASSERT(etl::is_integral<TValue>::value, "TValue not an integral type"); ETL_STATIC_ASSERT(etl::is_integral<TValue>::value, "TValue not an integral type");
ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type"); ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type");
ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type"); ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type");
ETL_STATIC_ASSERT(NBITS <= std::numeric_limits<TReturn>::digits, "NBITS too large for return type"); ETL_STATIC_ASSERT(NBITS <= ETL_STD::numeric_limits<TReturn>::digits, "NBITS too large for return type");
ETL_STATIC_ASSERT(SHIFT <= std::numeric_limits<TReturn>::digits, "SHIFT too large"); ETL_STATIC_ASSERT(SHIFT <= ETL_STD::numeric_limits<TReturn>::digits, "SHIFT too large");
struct S struct S
{ {
@ -283,7 +283,7 @@ namespace etl
ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type"); ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type");
ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type"); ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type");
ETL_ASSERT((NBITS <= std::numeric_limits<TReturn>::digits), ETL_ERROR(binary_out_of_range)); ETL_ASSERT((NBITS <= ETL_STD::numeric_limits<TReturn>::digits), ETL_ERROR(binary_out_of_range));
TReturn mask = TReturn(1) << (NBITS - 1); TReturn mask = TReturn(1) << (NBITS - 1);
value = value & static_cast<TValue>((TReturn(1) << NBITS) - 1); value = value & static_cast<TValue>((TReturn(1) << NBITS) - 1);
@ -304,7 +304,7 @@ namespace etl
ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type"); ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type");
ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type"); ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type");
ETL_ASSERT((NBITS <= std::numeric_limits<TReturn>::digits), ETL_ERROR(binary_out_of_range)); ETL_ASSERT((NBITS <= ETL_STD::numeric_limits<TReturn>::digits), ETL_ERROR(binary_out_of_range));
TReturn mask = TReturn(1) << (NBITS - 1); TReturn mask = TReturn(1) << (NBITS - 1);
value = (value >> SHIFT) & static_cast<TValue>((TReturn(1) << NBITS) - 1); value = (value >> SHIFT) & static_cast<TValue>((TReturn(1) << NBITS) - 1);

View File

@ -68,7 +68,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
bit_stream(char* begin_, char* end_) bit_stream(char* begin_, char* end_)
: pdata(reinterpret_cast<unsigned char*>(begin_)), : pdata(reinterpret_cast<unsigned char*>(begin_)),
length(std::distance(begin_, end_)) length(ETL_STD::distance(begin_, end_))
{ {
restart(); restart();
} }
@ -78,7 +78,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
bit_stream(unsigned char* begin_, unsigned char* end_) bit_stream(unsigned char* begin_, unsigned char* end_)
: pdata(begin_), : pdata(begin_),
length(std::distance(begin_, end_)) length(ETL_STD::distance(begin_, end_))
{ {
restart(); restart();
} }
@ -128,7 +128,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
void set_stream(char* begin_, char* end_) void set_stream(char* begin_, char* end_)
{ {
set_stream(begin_, std::distance(begin_, end_)); set_stream(begin_, ETL_STD::distance(begin_, end_));
} }
//*************************************************************************** //***************************************************************************
@ -136,7 +136,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
void set_stream(unsigned char* begin_, unsigned char* end_) void set_stream(unsigned char* begin_, unsigned char* end_)
{ {
set_stream(begin_, std::distance(begin_, end_)); set_stream(begin_, ETL_STD::distance(begin_, end_));
} }
//*************************************************************************** //***************************************************************************
@ -266,7 +266,7 @@ namespace etl
// Get the bits from the stream. // Get the bits from the stream.
while (width != 0) while (width != 0)
{ {
unsigned char mask_width = static_cast<unsigned char>(std::min(width, bits_in_byte)); unsigned char mask_width = static_cast<unsigned char>(ETL_STD::min(width, bits_in_byte));
unsigned char chunk = get_chunk(mask_width); unsigned char chunk = get_chunk(mask_width);
width -= mask_width; width -= mask_width;
@ -379,7 +379,7 @@ namespace etl
// Send the bits to the stream. // Send the bits to the stream.
while (width != 0) while (width != 0)
{ {
unsigned char mask_width = static_cast<unsigned char>(std::min(width, bits_in_byte)); unsigned char mask_width = static_cast<unsigned char>(ETL_STD::min(width, bits_in_byte));
width -= mask_width; width -= mask_width;
uint32_t mask = ((uint32_t(1U) << mask_width) - 1U) << width; uint32_t mask = ((uint32_t(1U) << mask_width) - 1U) << width;
@ -412,7 +412,7 @@ namespace etl
// Send the bits to the stream. // Send the bits to the stream.
while (width != 0) while (width != 0)
{ {
unsigned char mask_width = static_cast<unsigned char>(std::min(width, bits_in_byte)); unsigned char mask_width = static_cast<unsigned char>(ETL_STD::min(width, bits_in_byte));
width -= mask_width; width -= mask_width;
uint64_t mask = ((uint64_t(1U) << mask_width) - 1U) << width; uint64_t mask = ((uint64_t(1U) << mask_width) - 1U) << width;
@ -495,11 +495,11 @@ namespace etl
// Network to host. // Network to host.
if (etl::endianness::value() == etl::endian::little) if (etl::endianness::value() == etl::endian::little)
{ {
std::reverse_copy(data, data + sizeof(T), temp); ETL_STD::reverse_copy(data, data + sizeof(T), temp);
} }
else else
{ {
std::copy(data, data + sizeof(T), temp); ETL_STD::copy(data, data + sizeof(T), temp);
} }
value = *reinterpret_cast<T*>(temp); value = *reinterpret_cast<T*>(temp);
@ -516,11 +516,11 @@ namespace etl
// Host to network. // Host to network.
if (etl::endianness::value() == etl::endian::little) if (etl::endianness::value() == etl::endian::little)
{ {
std::reverse_copy(pf, pf + sizeof(T), data); ETL_STD::reverse_copy(pf, pf + sizeof(T), data);
} }
else else
{ {
std::copy(pf, pf + sizeof(T), data); ETL_STD::copy(pf, pf + sizeof(T), data);
} }
} }

View File

@ -312,7 +312,7 @@ namespace etl
{ {
reset(); reset();
size_t i = std::min(NBITS, etl::strlen(text)); size_t i = ETL_STD::min(NBITS, etl::strlen(text));
while (i > 0) while (i > 0)
{ {
@ -329,7 +329,7 @@ namespace etl
{ {
reset(); reset();
size_t i = std::min(NBITS, etl::strlen(text)); size_t i = ETL_STD::min(NBITS, etl::strlen(text));
while (i > 0) while (i > 0)
{ {
@ -346,7 +346,7 @@ namespace etl
{ {
reset(); reset();
size_t i = std::min(NBITS, etl::strlen(text)); size_t i = ETL_STD::min(NBITS, etl::strlen(text));
while (i > 0) while (i > 0)
{ {
@ -363,7 +363,7 @@ namespace etl
{ {
reset(); reset();
size_t i = std::min(NBITS, etl::strlen(text)); size_t i = ETL_STD::min(NBITS, etl::strlen(text));
while (i > 0) while (i > 0)
{ {
@ -380,7 +380,7 @@ namespace etl
{ {
reset(); reset();
size_t i = std::min(NBITS, etl::strlen(text)); size_t i = ETL_STD::min(NBITS, etl::strlen(text));
while (i > 0) while (i > 0)
{ {
@ -746,7 +746,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void swap(ibitset& other) void swap(ibitset& other)
{ {
std::swap_ranges(pdata, pdata + SIZE, other.pdata); ETL_STD::swap_ranges(pdata, pdata + SIZE, other.pdata);
} }
protected: protected:
@ -818,7 +818,7 @@ namespace etl
//************************************************************************* //*************************************************************************
static bool is_equal(const ibitset& lhs, const ibitset&rhs) static bool is_equal(const ibitset& lhs, const ibitset&rhs)
{ {
return std::equal(lhs.pdata, lhs.pdata + lhs.SIZE, rhs.pdata); return ETL_STD::equal(lhs.pdata, lhs.pdata + lhs.SIZE, rhs.pdata);
} }
element_t TOP_MASK; element_t TOP_MASK;

View File

@ -39,6 +39,7 @@ SOFTWARE.
#include "static_assert.h" #include "static_assert.h"
#include "timer.h" #include "timer.h"
#include "atomic.h" #include "atomic.h"
#include "error_handler.h"
#if ETL_CPP11_SUPPORTED #if ETL_CPP11_SUPPORTED
#include "delegate.h" #include "delegate.h"
@ -47,18 +48,27 @@ SOFTWARE.
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "43" #define ETL_FILE "43"
#if !defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK) #if defined(ETL_IN_UNIT_TEST) && defined(ETL_NO_STL)
#error ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK not defined #define ETL_DISABLE_TIMER_UPDATES
#endif #define ETL_ENABLE_TIMER_UPDATES
#define ETL_TIMER_UPDATES_ENABLED true
#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK) #undef ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK
#error Only define one of ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK #undef ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK
#endif #else
#if !defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK)
#error ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK not defined
#endif
#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) #if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK)
#define ETL_DISABLE_TIMER_UPDATES (++process_semaphore) #error Only define one of ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK
#define ETL_ENABLE_TIMER_UPDATES (--process_semaphore) #endif
#define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0)
#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK)
#define ETL_DISABLE_TIMER_UPDATES (++process_semaphore)
#define ETL_ENABLE_TIMER_UPDATES (--process_semaphore)
#define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0)
#endif
#endif #endif
#if defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK) #if defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK)

View File

@ -141,7 +141,7 @@ namespace etl
{ {
if (p != 0) if (p != 0)
{ {
std::fill_n(p, n, c); ETL_STD::fill_n(p, n, c);
} }
return p; return p;
@ -156,9 +156,9 @@ namespace etl
} }
else else
{ {
etl::copy_n(std::reverse_iterator<char_type*>(src + count), etl::copy_n(ETL_STD::reverse_iterator<char_type*>(src + count),
count, count,
std::reverse_iterator<char_type*>(dest + count)); ETL_STD::reverse_iterator<char_type*>(dest + count));
} }
return dest; return dest;

View File

@ -48,7 +48,7 @@ namespace etl
/// Defines <=, >, >= interms of < /// Defines <=, >, >= interms of <
/// Default /// Default
//*************************************************************************** //***************************************************************************
template <typename T, typename TLess = std::less<T> > template <typename T, typename TLess = ETL_STD::less<T> >
struct compare struct compare
{ {
typedef typename etl::parameter_type<T>::type first_argument_type; typedef typename etl::parameter_type<T>::type first_argument_type;

View File

@ -177,9 +177,9 @@ namespace etl
///\ingroup container ///\ingroup container
//***************************************************************************** //*****************************************************************************
template<typename TValue, const size_t ARRAY_SIZE> template<typename TValue, const size_t ARRAY_SIZE>
ETL_CONSTEXPR std::reverse_iterator<TValue*> rbegin(const TValue(&data)[ARRAY_SIZE]) ETL_CONSTEXPR ETL_STD::reverse_iterator<TValue*> rbegin(const TValue(&data)[ARRAY_SIZE])
{ {
return std::reverse_iterator<TValue*>(&data[ARRAY_SIZE]); return ETL_STD::reverse_iterator<TValue*>(&data[ARRAY_SIZE]);
} }
//***************************************************************************** //*****************************************************************************
@ -187,9 +187,9 @@ namespace etl
///\ingroup container ///\ingroup container
//***************************************************************************** //*****************************************************************************
template<typename TValue, const size_t ARRAY_SIZE> template<typename TValue, const size_t ARRAY_SIZE>
ETL_CONSTEXPR std::reverse_iterator<const TValue*> crbegin(const TValue(&data)[ARRAY_SIZE]) ETL_CONSTEXPR ETL_STD::reverse_iterator<const TValue*> crbegin(const TValue(&data)[ARRAY_SIZE])
{ {
return std::reverse_iterator<const TValue*>(&data[ARRAY_SIZE]); return ETL_STD::reverse_iterator<const TValue*>(&data[ARRAY_SIZE]);
} }
//***************************************************************************** //*****************************************************************************
@ -227,9 +227,9 @@ namespace etl
///\ingroup container ///\ingroup container
//***************************************************************************** //*****************************************************************************
template<typename TValue, const size_t ARRAY_SIZE> template<typename TValue, const size_t ARRAY_SIZE>
ETL_CONSTEXPR std::reverse_iterator<TValue*> rend(const TValue(&data)[ARRAY_SIZE]) ETL_CONSTEXPR ETL_STD::reverse_iterator<TValue*> rend(const TValue(&data)[ARRAY_SIZE])
{ {
return std::reverse_iterator<TValue*>(&data[0]); return ETL_STD::reverse_iterator<TValue*>(&data[0]);
} }
//***************************************************************************** //*****************************************************************************
@ -237,9 +237,9 @@ namespace etl
///\ingroup container ///\ingroup container
//***************************************************************************** //*****************************************************************************
template<typename TValue, const size_t ARRAY_SIZE> template<typename TValue, const size_t ARRAY_SIZE>
ETL_CONSTEXPR std::reverse_iterator<const TValue*> crend(const TValue(&data)[ARRAY_SIZE]) ETL_CONSTEXPR ETL_STD::reverse_iterator<const TValue*> crend(const TValue(&data)[ARRAY_SIZE])
{ {
return std::reverse_iterator<const TValue*>(&data[0]); return ETL_STD::reverse_iterator<const TValue*>(&data[0]);
} }
//***************************************************************************** //*****************************************************************************
@ -249,7 +249,7 @@ namespace etl
template<class TIterator> template<class TIterator>
TIterator next(TIterator iterator, ptrdiff_t n = 1) TIterator next(TIterator iterator, ptrdiff_t n = 1)
{ {
std::advance(iterator, n); ETL_STD::advance(iterator, n);
return iterator; return iterator;
} }
@ -260,7 +260,7 @@ namespace etl
template<class TIterator> template<class TIterator>
TIterator prev(TIterator iterator, ptrdiff_t n = 1) TIterator prev(TIterator iterator, ptrdiff_t n = 1)
{ {
std::advance(iterator, -n); ETL_STD::advance(iterator, -n);
return iterator; return iterator;
} }

View File

@ -180,7 +180,7 @@ namespace etl
{ {
ETL_ASSERT(position < this->size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position < this->size(), ETL_ERROR(string_out_of_bounds));
length_ = std::min(length_, this->size() - position); length_ = ETL_STD::min(length_, this->size() - position);
new_string.assign(buffer + position, buffer + position + length_); new_string.assign(buffer + position, buffer + position + length_);
} }

View File

@ -257,7 +257,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void swap(cyclic_value<T, FIRST, LAST>& other) void swap(cyclic_value<T, FIRST, LAST>& other)
{ {
std::swap(value, other.value); ETL_STD::swap(value, other.value);
} }
//************************************************************************* //*************************************************************************
@ -531,9 +531,9 @@ namespace etl
//************************************************************************* //*************************************************************************
void swap(cyclic_value<T, FIRST, LAST>& other) void swap(cyclic_value<T, FIRST, LAST>& other)
{ {
std::swap(first_value, other.first_value); ETL_STD::swap(first_value, other.first_value);
std::swap(last_value, other.last_value); ETL_STD::swap(last_value, other.last_value);
std::swap(value, other.value); ETL_STD::swap(value, other.value);
} }
//************************************************************************* //*************************************************************************

View File

@ -51,6 +51,7 @@ SOFTWARE.
#include "debug_count.h" #include "debug_count.h"
#include "algorithm.h" #include "algorithm.h"
#include "type_traits.h" #include "type_traits.h"
#include "iterator.h"
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
#include <initializer_list> #include <initializer_list>
@ -238,7 +239,7 @@ namespace etl
#endif #endif
typedef T* pointer; typedef T* pointer;
typedef const T* const_pointer; typedef const T* const_pointer;
typedef typename std::iterator_traits<pointer>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<pointer>::difference_type difference_type;
protected: protected:
@ -255,7 +256,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Iterator /// Iterator
//************************************************************************* //*************************************************************************
struct iterator : public std::iterator<std::random_access_iterator_tag, T> struct iterator : public etl::iterator<ETL_RANDOM_ACCESS_ITERATOR_TAG, T>
{ {
friend class ideque; friend class ideque;
@ -420,7 +421,7 @@ namespace etl
//*************************************************** //***************************************************
void swap(iterator& other) void swap(iterator& other)
{ {
std::swap(index, other.index); ETL_STD::swap(index, other.index);
} }
private: private:
@ -441,7 +442,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Const Iterator /// Const Iterator
//************************************************************************* //*************************************************************************
struct const_iterator : public std::iterator<std::random_access_iterator_tag, const T> struct const_iterator : public etl::iterator<ETL_RANDOM_ACCESS_ITERATOR_TAG, const T>
{ {
friend class ideque; friend class ideque;
@ -602,7 +603,7 @@ namespace etl
//*************************************************** //***************************************************
void swap(const_iterator& other) void swap(const_iterator& other)
{ {
std::swap(index, other.index); ETL_STD::swap(index, other.index);
} }
private: private:
@ -633,8 +634,8 @@ namespace etl
pointer p_buffer; pointer p_buffer;
}; };
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//************************************************************************* //*************************************************************************
/// Assigns a range to the deque. /// Assigns a range to the deque.
@ -892,13 +893,13 @@ namespace etl
else else
{ {
// Are we closer to the front? // Are we closer to the front?
if (std::distance(_begin, position) < std::distance(position, _end - 1)) if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1))
{ {
// Construct the _begin. // Construct the _begin.
create_element_front(*_begin); create_element_front(*_begin);
// Move the values. // Move the values.
std::copy(_begin + 1, position, _begin); ETL_STD::copy(_begin + 1, position, _begin);
// Write the new value. // Write the new value.
*--position = value; *--position = value;
@ -909,7 +910,7 @@ namespace etl
create_element_back(*(_end - 1)); create_element_back(*(_end - 1));
// Move the values. // Move the values.
std::copy_backward(position, _end - 2, _end - 1); ETL_STD::copy_backward(position, _end - 2, _end - 1);
// Write the new value. // Write the new value.
*position = value; *position = value;
@ -934,38 +935,38 @@ namespace etl
if (insert_position == begin()) if (insert_position == begin())
{ {
create_element_front(std::move(value)); create_element_front(ETL_STD::move(value));
position = _begin; position = _begin;
} }
else if (insert_position == end()) else if (insert_position == end())
{ {
create_element_back(std::move(value)); create_element_back(ETL_STD::move(value));
position = _end - 1; position = _end - 1;
} }
else else
{ {
// Are we closer to the front? // Are we closer to the front?
if (std::distance(_begin, position) < std::distance(position, _end - 1)) if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1))
{ {
// Construct the _begin. // Construct the _begin.
create_element_front(std::move(*_begin)); create_element_front(ETL_STD::move(*_begin));
// Move the values. // Move the values.
std::move(_begin + 1, position, _begin); ETL_STD::move(_begin + 1, position, _begin);
// Write the new value. // Write the new value.
*--position = std::move(value); *--position = ETL_STD::move(value);
} }
else else
{ {
// Construct the _end. // Construct the _end.
create_element_back(std::move(*(_end - 1))); create_element_back(ETL_STD::move(*(_end - 1)));
// Move the values. // Move the values.
std::move_backward(position, _end - 2, _end - 1); ETL_STD::move_backward(position, _end - 2, _end - 1);
// Write the new value. // Write the new value.
*position = std::move(value); *position = ETL_STD::move(value);
} }
} }
@ -1007,13 +1008,13 @@ namespace etl
else else
{ {
// Are we closer to the front? // Are we closer to the front?
if (std::distance(_begin, position) < std::distance(position, _end - 1)) if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1))
{ {
// Construct the _begin. // Construct the _begin.
create_element_front(*_begin); create_element_front(*_begin);
// Move the values. // Move the values.
std::copy(_begin + 1, position, _begin); ETL_STD::copy(_begin + 1, position, _begin);
// Write the new value. // Write the new value.
--position; --position;
@ -1026,7 +1027,7 @@ namespace etl
create_element_back(*(_end - 1)); create_element_back(*(_end - 1));
// Move the values. // Move the values.
std::copy_backward(position, _end - 2, _end - 1); ETL_STD::copy_backward(position, _end - 2, _end - 1);
// Write the new value. // Write the new value.
(*position).~T(); (*position).~T();
@ -1034,7 +1035,7 @@ namespace etl
} }
} }
::new (p) T(std::forward<Args>(args)...); ::new (p) T(ETL_STD::forward<Args>(args)...);
return position; return position;
} }
@ -1074,13 +1075,13 @@ namespace etl
else else
{ {
// Are we closer to the front? // Are we closer to the front?
if (std::distance(_begin, position) < std::distance(position, _end - 1)) if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1))
{ {
// Construct the _begin. // Construct the _begin.
create_element_front(*_begin); create_element_front(*_begin);
// Move the values. // Move the values.
std::copy(_begin + 1, position, _begin); ETL_STD::copy(_begin + 1, position, _begin);
// Write the new value. // Write the new value.
--position; --position;
@ -1093,7 +1094,7 @@ namespace etl
create_element_back(*(_end - 1)); create_element_back(*(_end - 1));
// Move the values. // Move the values.
std::copy_backward(position, _end - 2, _end - 1); ETL_STD::copy_backward(position, _end - 2, _end - 1);
// Write the new value. // Write the new value.
(*position).~T(); (*position).~T();
@ -1139,13 +1140,13 @@ namespace etl
else else
{ {
// Are we closer to the front? // Are we closer to the front?
if (std::distance(_begin, position) < std::distance(position, _end - 1)) if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1))
{ {
// Construct the _begin. // Construct the _begin.
create_element_front(*_begin); create_element_front(*_begin);
// Move the values. // Move the values.
std::copy(_begin + 1, position, _begin); ETL_STD::copy(_begin + 1, position, _begin);
// Write the new value. // Write the new value.
--position; --position;
@ -1158,7 +1159,7 @@ namespace etl
create_element_back(*(_end - 1)); create_element_back(*(_end - 1));
// Move the values. // Move the values.
std::copy_backward(position, _end - 2, _end - 1); ETL_STD::copy_backward(position, _end - 2, _end - 1);
// Write the new value. // Write the new value.
(*position).~T(); (*position).~T();
@ -1204,13 +1205,13 @@ namespace etl
else else
{ {
// Are we closer to the front? // Are we closer to the front?
if (std::distance(_begin, position) < std::distance(position, _end - 1)) if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1))
{ {
// Construct the _begin. // Construct the _begin.
create_element_front(*_begin); create_element_front(*_begin);
// Move the values. // Move the values.
std::copy(_begin + 1, position, _begin); ETL_STD::copy(_begin + 1, position, _begin);
// Write the new value. // Write the new value.
--position; --position;
@ -1223,7 +1224,7 @@ namespace etl
create_element_back(*(_end - 1)); create_element_back(*(_end - 1));
// Move the values. // Move the values.
std::copy_backward(position, _end - 2, _end - 1); ETL_STD::copy_backward(position, _end - 2, _end - 1);
// Write the new value. // Write the new value.
(*position).~T(); (*position).~T();
@ -1269,13 +1270,13 @@ namespace etl
else else
{ {
// Are we closer to the front? // Are we closer to the front?
if (std::distance(_begin, position) < std::distance(position, _end - 1)) if (ETL_STD::distance(_begin, position) < ETL_STD::distance(position, _end - 1))
{ {
// Construct the _begin. // Construct the _begin.
create_element_front(*_begin); create_element_front(*_begin);
// Move the values. // Move the values.
std::copy(_begin + 1, position, _begin); ETL_STD::copy(_begin + 1, position, _begin);
// Write the new value. // Write the new value.
--position; --position;
@ -1288,7 +1289,7 @@ namespace etl
create_element_back(*(_end - 1)); create_element_back(*(_end - 1));
// Move the values. // Move the values.
std::copy_backward(position, _end - 2, _end - 1); ETL_STD::copy_backward(position, _end - 2, _end - 1);
// Write the new value. // Write the new value.
(*position).~T(); (*position).~T();
@ -1342,8 +1343,8 @@ namespace etl
if (distance(_begin, insert_position) <= difference_type(current_size / 2)) if (distance(_begin, insert_position) <= difference_type(current_size / 2))
{ {
size_t n_insert = n; size_t n_insert = n;
size_t n_move = std::distance(begin(), position); size_t n_move = ETL_STD::distance(begin(), position);
size_t n_create_copy = std::min(n_insert, n_move); size_t n_create_copy = ETL_STD::min(n_insert, n_move);
size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0; size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0;
size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0; size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0;
size_t n_copy_old = n_move - n_create_copy; size_t n_copy_old = n_move - n_create_copy;
@ -1371,15 +1372,15 @@ namespace etl
// Copy new. // Copy new.
to = position - n_create_copy; to = position - n_create_copy;
std::fill_n(to, n_copy_new, value); ETL_STD::fill_n(to, n_copy_new, value);
position = _begin + n_move; position = _begin + n_move;
} }
else else
{ {
size_t n_insert = n; size_t n_insert = n;
size_t n_move = std::distance(position, end()); size_t n_move = ETL_STD::distance(position, end());
size_t n_create_copy = std::min(n_insert, n_move); size_t n_create_copy = ETL_STD::min(n_insert, n_move);
size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0; size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0;
size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0; size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0;
size_t n_copy_old = n_move - n_create_copy; size_t n_copy_old = n_move - n_create_copy;
@ -1399,10 +1400,10 @@ namespace etl
} }
// Copy old. // Copy old.
std::copy_backward(position, position + n_copy_old, position + n_insert + n_copy_old); ETL_STD::copy_backward(position, position + n_copy_old, position + n_insert + n_copy_old);
// Copy new. // Copy new.
std::fill_n(position, n_copy_new, value); ETL_STD::fill_n(position, n_copy_new, value);
} }
} }
@ -1422,7 +1423,7 @@ namespace etl
{ {
iterator position; iterator position;
difference_type n = std::distance(range_begin, range_end); difference_type n = ETL_STD::distance(range_begin, range_end);
ETL_ASSERT((current_size + n) <= CAPACITY, ETL_ERROR(deque_full)); ETL_ASSERT((current_size + n) <= CAPACITY, ETL_ERROR(deque_full));
@ -1450,8 +1451,8 @@ namespace etl
if (distance(_begin, insert_position) < difference_type(current_size / 2)) if (distance(_begin, insert_position) < difference_type(current_size / 2))
{ {
size_t n_insert = n; size_t n_insert = n;
size_t n_move = std::distance(begin(), position); size_t n_move = ETL_STD::distance(begin(), position);
size_t n_create_copy = std::min(n_insert, n_move); size_t n_create_copy = ETL_STD::min(n_insert, n_move);
size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0; size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0;
size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0; size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0;
size_t n_copy_old = n_move - n_create_copy; size_t n_copy_old = n_move - n_create_copy;
@ -1481,8 +1482,8 @@ namespace etl
else else
{ {
size_t n_insert = n; size_t n_insert = n;
size_t n_move = std::distance(position, end()); size_t n_move = ETL_STD::distance(position, end());
size_t n_create_copy = std::min(n_insert, n_move); size_t n_create_copy = ETL_STD::min(n_insert, n_move);
size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0; size_t n_create_new = (n_insert > n_create_copy) ? n_insert - n_create_copy : 0;
size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0; size_t n_copy_new = (n_insert > n_create_new) ? n_insert - n_create_new : 0;
size_t n_copy_old = n_move - n_create_copy; size_t n_copy_old = n_move - n_create_copy;
@ -1503,7 +1504,7 @@ namespace etl
} }
// Copy old. // Copy old.
std::copy_backward(position, position + n_copy_old, position + n_insert + n_copy_old); ETL_STD::copy_backward(position, position + n_copy_old, position + n_insert + n_copy_old);
// Copy new. // Copy new.
item = range_begin; item = range_begin;
@ -1540,13 +1541,13 @@ namespace etl
// Are we closer to the front? // Are we closer to the front?
if (distance(_begin, position) < difference_type(current_size / 2)) if (distance(_begin, position) < difference_type(current_size / 2))
{ {
std::copy_backward(_begin, position, position + 1); ETL_STD::copy_backward(_begin, position, position + 1);
destroy_element_front(); destroy_element_front();
++position; ++position;
} }
else else
{ {
std::copy(position + 1, _end, position); ETL_STD::copy(position + 1, _end, position);
destroy_element_back(); destroy_element_back();
} }
} }
@ -1567,7 +1568,7 @@ namespace etl
ETL_ASSERT((distance(range_begin) <= difference_type(current_size)) && (distance(range_end) <= difference_type(current_size)), ETL_ERROR(deque_out_of_bounds)); ETL_ASSERT((distance(range_begin) <= difference_type(current_size)) && (distance(range_end) <= difference_type(current_size)), ETL_ERROR(deque_out_of_bounds));
// How many to erase? // How many to erase?
size_t length = std::distance(range_begin, range_end); size_t length = ETL_STD::distance(range_begin, range_end);
// At the beginning? // At the beginning?
if (position == _begin) if (position == _begin)
@ -1596,7 +1597,7 @@ namespace etl
if (distance(_begin, position) < difference_type(current_size / 2)) if (distance(_begin, position) < difference_type(current_size / 2))
{ {
// Move the items. // Move the items.
std::copy_backward(_begin, position, position + length); ETL_STD::copy_backward(_begin, position, position + length);
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
{ {
@ -1609,7 +1610,7 @@ namespace etl
// Must be closer to the back. // Must be closer to the back.
{ {
// Move the items. // Move the items.
std::copy(position + length, _end, position); ETL_STD::copy(position + length, _end, position);
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
{ {
@ -1645,7 +1646,7 @@ namespace etl
#if defined(ETL_CHECK_PUSH_POP) #if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full)); ETL_ASSERT(!full(), ETL_ERROR(deque_full));
#endif #endif
create_element_back(std::move(item)); create_element_back(ETL_STD::move(item));
} }
#endif #endif
@ -1661,7 +1662,7 @@ namespace etl
ETL_ASSERT(!full(), ETL_ERROR(deque_full)); ETL_ASSERT(!full(), ETL_ERROR(deque_full));
#endif #endif
::new (&(*_end)) T(std::forward<Args>(args)...); ::new (&(*_end)) T(ETL_STD::forward<Args>(args)...);
++_end; ++_end;
++current_size; ++current_size;
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
@ -1773,7 +1774,7 @@ namespace etl
#if defined(ETL_CHECK_PUSH_POP) #if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full)); ETL_ASSERT(!full(), ETL_ERROR(deque_full));
#endif #endif
create_element_front(std::move(item)); create_element_front(ETL_STD::move(item));
} }
#endif #endif
@ -1790,7 +1791,7 @@ namespace etl
#endif #endif
--_begin; --_begin;
::new (&(*_begin)) T(std::forward<Args>(args)...); ::new (&(*_begin)) T(ETL_STD::forward<Args>(args)...);
++current_size; ++current_size;
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
} }
@ -1964,7 +1965,7 @@ namespace etl
iterator itr = rhs.begin(); iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
push_back(std::move(*itr)); push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -2116,7 +2117,7 @@ namespace etl
void create_element_front(rvalue_reference value) void create_element_front(rvalue_reference value)
{ {
--_begin; --_begin;
::new (&(*_begin)) T(std::move(value)); ::new (&(*_begin)) T(ETL_STD::move(value));
++current_size; ++current_size;
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
} }
@ -2126,7 +2127,7 @@ namespace etl
//********************************************************************* //*********************************************************************
void create_element_back(rvalue_reference value) void create_element_back(rvalue_reference value)
{ {
::new (&(*_end)) T(std::move(value)); ::new (&(*_end)) T(ETL_STD::move(value));
++_end; ++_end;
++current_size; ++current_size;
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
@ -2232,7 +2233,7 @@ namespace etl
typedef T& reference; typedef T& reference;
typedef const T& const_reference; typedef const T& const_reference;
typedef size_t size_type; typedef size_t size_type;
typedef typename std::iterator_traits<pointer>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<pointer>::difference_type difference_type;
//************************************************************************* //*************************************************************************
/// Default constructor. /// Default constructor.
@ -2277,7 +2278,7 @@ namespace etl
typename etl::ideque<T>::iterator itr = other.begin(); typename etl::ideque<T>::iterator itr = other.begin();
while (itr != other.end()) while (itr != other.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -2341,7 +2342,7 @@ namespace etl
typename etl::ideque<T>::iterator itr = rhs.begin(); typename etl::ideque<T>::iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -2361,7 +2362,7 @@ namespace etl
void repair() void repair()
{ {
#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
ETL_ASSERT(std::is_trivially_copyable<T>::value, ETL_ERROR(etl::deque_incompatible_type)); ETL_ASSERT(etl::is_trivially_copyable<T>::value, ETL_ERROR(etl::deque_incompatible_type));
#endif #endif
etl::ideque<T>::repair_buffer(reinterpret_cast<T*>(&buffer[0])); etl::ideque<T>::repair_buffer(reinterpret_cast<T*>(&buffer[0]));
@ -2383,7 +2384,7 @@ namespace etl
template <typename T> template <typename T>
bool operator ==(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs) bool operator ==(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -2409,7 +2410,7 @@ namespace etl
template <typename T> template <typename T>
bool operator <(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs) bool operator <(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), return ETL_STD::lexicographical_compare(lhs.begin(),
lhs.end(), lhs.end(),
rhs.begin(), rhs.begin(),
rhs.end()); rhs.end());

View File

@ -32,6 +32,7 @@ SOFTWARE.
#define ETL_FIXED_ITERATOR_INCLUDED #define ETL_FIXED_ITERATOR_INCLUDED
#include "platform.h" #include "platform.h"
#include "iterator.h"
#include "stl/iterator.h" #include "stl/iterator.h"
@ -44,7 +45,7 @@ namespace etl
/// This can be useful when using STL algorithms to interact with fixed memory locations such as registers. /// This can be useful when using STL algorithms to interact with fixed memory locations such as registers.
///\ingroup iterator ///\ingroup iterator
template <typename TIterator> template <typename TIterator>
class fixed_iterator : std::iterator<typename std::iterator_traits<TIterator>::iterator_category, typename std::iterator_traits<TIterator>::value_type> class fixed_iterator : etl::iterator<typename ETL_STD::iterator_traits<TIterator>::iterator_category, typename ETL_STD::iterator_traits<TIterator>::value_type>
{ {
public: public:
@ -99,7 +100,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
/// Dereference operator. /// Dereference operator.
//*************************************************************************** //***************************************************************************
typename std::iterator_traits<TIterator>::value_type operator *() typename ETL_STD::iterator_traits<TIterator>::value_type operator *()
{ {
return *it; return *it;
} }
@ -107,7 +108,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
/// Dereference operator. /// Dereference operator.
//*************************************************************************** //***************************************************************************
const typename std::iterator_traits<TIterator>::value_type operator *() const const typename ETL_STD::iterator_traits<TIterator>::value_type operator *() const
{ {
return *it; return *it;
} }
@ -139,7 +140,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
/// += operator. /// += operator.
//*************************************************************************** //***************************************************************************
fixed_iterator& operator +=(typename std::iterator_traits<TIterator>::difference_type /*offset*/) fixed_iterator& operator +=(typename ETL_STD::iterator_traits<TIterator>::difference_type /*offset*/)
{ {
return *this; return *this;
} }
@ -147,7 +148,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
/// -= operator. /// -= operator.
//*************************************************************************** //***************************************************************************
fixed_iterator& operator -=(typename std::iterator_traits<TIterator>::difference_type /*offset*/) fixed_iterator& operator -=(typename ETL_STD::iterator_traits<TIterator>::difference_type /*offset*/)
{ {
return *this; return *this;
} }
@ -180,7 +181,7 @@ namespace etl
//***************************************************************************** //*****************************************************************************
template <typename TIterator> template <typename TIterator>
etl::fixed_iterator<TIterator>& operator +(etl::fixed_iterator<TIterator>& lhs, etl::fixed_iterator<TIterator>& operator +(etl::fixed_iterator<TIterator>& lhs,
typename std::iterator_traits<TIterator>::difference_type /*rhs*/) typename ETL_STD::iterator_traits<TIterator>::difference_type /*rhs*/)
{ {
return lhs; return lhs;
} }
@ -190,7 +191,7 @@ namespace etl
//***************************************************************************** //*****************************************************************************
template <typename TIterator> template <typename TIterator>
etl::fixed_iterator<TIterator>& operator -(etl::fixed_iterator<TIterator>& lhs, etl::fixed_iterator<TIterator>& operator -(etl::fixed_iterator<TIterator>& lhs,
typename std::iterator_traits<TIterator>::difference_type /*rhs*/) typename ETL_STD::iterator_traits<TIterator>::difference_type /*rhs*/)
{ {
return lhs; return lhs;
} }
@ -199,7 +200,7 @@ namespace etl
/// - fixed_iterator operator. /// - fixed_iterator operator.
//***************************************************************************** //*****************************************************************************
template <typename TIterator> template <typename TIterator>
typename std::iterator_traits<TIterator>::difference_type operator -(etl::fixed_iterator<TIterator>& lhs, typename ETL_STD::iterator_traits<TIterator>::difference_type operator -(etl::fixed_iterator<TIterator>& lhs,
etl::fixed_iterator<TIterator>& rhs) etl::fixed_iterator<TIterator>& rhs)
{ {
return TIterator(lhs) - TIterator(rhs); return TIterator(lhs) - TIterator(rhs);

View File

@ -60,7 +60,7 @@ namespace etl
/// Can be used as a reference type for all flat_maps containing a specific type. /// Can be used as a reference type for all flat_maps containing a specific type.
///\ingroup flat_map ///\ingroup flat_map
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TMapped, typename TKeyCompare = std::less<TKey> > template <typename TKey, typename TMapped, typename TKeyCompare = ETL_STD::less<TKey> >
class iflat_map : private etl::ireference_flat_map<TKey, TMapped, TKeyCompare> class iflat_map : private etl::ireference_flat_map<TKey, TMapped, TKeyCompare>
{ {
private: private:
@ -72,7 +72,7 @@ namespace etl
public: public:
typedef std::pair<const TKey, TMapped> value_type; typedef ETL_PAIR<const TKey, TMapped> value_type;
typedef TKey key_type; typedef TKey key_type;
typedef TMapped mapped_type; typedef TMapped mapped_type;
typedef TKeyCompare key_compare; typedef TKeyCompare key_compare;
@ -85,9 +85,9 @@ namespace etl
typedef typename refmap_t::iterator iterator; typedef typename refmap_t::iterator iterator;
typedef typename refmap_t::const_iterator const_iterator; typedef typename refmap_t::const_iterator const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -232,7 +232,7 @@ namespace etl
//********************************************************************* //*********************************************************************
mapped_type& operator [](key_parameter_t key) mapped_type& operator [](key_parameter_t key)
{ {
return insert(std::make_pair(key, mapped_type())).first->second; return insert(ETL_MAKE_PAIR(key, mapped_type())).first->second;
} }
//********************************************************************* //*********************************************************************
@ -268,7 +268,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_map_full)); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_map_full));
#endif #endif
@ -285,11 +285,11 @@ namespace etl
/// If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full. /// If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(const_reference value) ETL_PAIR<iterator, bool> insert(const_reference value)
{ {
iterator i_element = lower_bound(value.first); iterator i_element = lower_bound(value.first);
std::pair<iterator, bool> result(i_element, false); ETL_PAIR<iterator, bool> result(i_element, false);
// Doesn't already exist? // Doesn't already exist?
if ((i_element == end()) || compare(value.first, i_element->first)) if ((i_element == end()) || compare(value.first, i_element->first))
@ -335,7 +335,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
std::pair<iterator, bool> emplace(const value_type& value) ETL_PAIR<iterator, bool> emplace(const value_type& value)
{ {
return emplace(value.first, value.second); return emplace(value.first, value.second);
} }
@ -345,18 +345,18 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename ... Args> template <typename ... Args>
std::pair<iterator, bool> emplace(const key_type& key, Args && ... args) ETL_PAIR<iterator, bool> emplace(const key_type& key, Args && ... args)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_map_full));
// Create it. // Create it.
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(std::forward<Args>(args)...); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(ETL_STD::forward<Args>(args)...);
iterator i_element = lower_bound(key); iterator i_element = lower_bound(key);
std::pair<iterator, bool> result(i_element, false); ETL_PAIR<iterator, bool> result(i_element, false);
// Doesn't already exist? // Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first)) if ((i_element == end()) || compare(key, i_element->first))
@ -379,7 +379,7 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename T1> template <typename T1>
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1) ETL_PAIR<iterator, bool> emplace(const key_type& key, const T1& value1)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_map_full));
@ -390,7 +390,7 @@ namespace etl
iterator i_element = lower_bound(key); iterator i_element = lower_bound(key);
std::pair<iterator, bool> result(i_element, false); ETL_PAIR<iterator, bool> result(i_element, false);
// Doesn't already exist? // Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first)) if ((i_element == end()) || compare(key, i_element->first))
@ -411,7 +411,7 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2> template <typename T1, typename T2>
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2) ETL_PAIR<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_map_full));
@ -422,7 +422,7 @@ namespace etl
iterator i_element = lower_bound(key); iterator i_element = lower_bound(key);
std::pair<iterator, bool> result(i_element, false); ETL_PAIR<iterator, bool> result(i_element, false);
// Doesn't already exist? // Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first)) if ((i_element == end()) || compare(key, i_element->first))
@ -443,7 +443,7 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2, typename T3> template <typename T1, typename T2, typename T3>
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3) ETL_PAIR<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_map_full));
@ -454,7 +454,7 @@ namespace etl
iterator i_element = lower_bound(key); iterator i_element = lower_bound(key);
std::pair<iterator, bool> result(i_element, false); ETL_PAIR<iterator, bool> result(i_element, false);
// Doesn't already exist? // Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first)) if ((i_element == end()) || compare(key, i_element->first))
@ -475,7 +475,7 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2, typename T3, typename T4> template <typename T1, typename T2, typename T3, typename T4>
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4) ETL_PAIR<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_map_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_map_full));
@ -486,7 +486,7 @@ namespace etl
iterator i_element = lower_bound(key); iterator i_element = lower_bound(key);
std::pair<iterator, bool> result(i_element, false); ETL_PAIR<iterator, bool> result(i_element, false);
// Doesn't already exist? // Doesn't already exist?
if ((i_element == end()) || compare(key, i_element->first)) if ((i_element == end()) || compare(key, i_element->first))
@ -662,7 +662,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
return refmap_t::equal_range(key); return refmap_t::equal_range(key);
} }
@ -672,7 +672,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
return refmap_t::equal_range(key); return refmap_t::equal_range(key);
} }
@ -793,7 +793,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::iflat_map<TKey, TMapped, TKeyCompare>& lhs, const etl::iflat_map<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::iflat_map<TKey, TMapped, TKeyCompare>& lhs, const etl::iflat_map<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -813,11 +813,11 @@ namespace etl
/// A flat_map implementation that uses a fixed size buffer. /// A flat_map implementation that uses a fixed size buffer.
///\tparam TKey The key type. ///\tparam TKey The key type.
///\tparam TValue The value type. ///\tparam TValue The value type.
///\tparam TCompare The type to compare keys. Default = std::less<TKey> ///\tparam TCompare The type to compare keys. Default = ETL_STD::less<TKey>
///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\tparam MAX_SIZE_ The maximum number of elements that can be stored.
///\ingroup flat_map ///\ingroup flat_map
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = std::less<TKey> > template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<TKey> >
class flat_map : public etl::iflat_map<TKey, TValue, TCompare> class flat_map : public etl::iflat_map<TKey, TValue, TCompare>
{ {
public: public:

View File

@ -59,12 +59,12 @@ namespace etl
/// Can be used as a reference type for all flat_multimaps containing a specific type. /// Can be used as a reference type for all flat_multimaps containing a specific type.
///\ingroup flat_multimap ///\ingroup flat_multimap
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TMapped, typename TKeyCompare = std::less<TKey> > template <typename TKey, typename TMapped, typename TKeyCompare = ETL_STD::less<TKey> >
class iflat_multimap : public etl::ireference_flat_multimap<TKey, TMapped, TKeyCompare> class iflat_multimap : public etl::ireference_flat_multimap<TKey, TMapped, TKeyCompare>
{ {
public: public:
typedef std::pair<const TKey, TMapped> value_type; typedef ETL_PAIR<const TKey, TMapped> value_type;
private: private:
@ -86,9 +86,9 @@ namespace etl
typedef typename refmap_t::iterator iterator; typedef typename refmap_t::iterator iterator;
typedef typename refmap_t::const_iterator const_iterator; typedef typename refmap_t::const_iterator const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -237,7 +237,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multimap_full));
#endif #endif
@ -254,11 +254,11 @@ namespace etl
/// If asserts or exceptions are enabled, emits flat_multimap_full if the flat_multimap is already full. /// If asserts or exceptions are enabled, emits flat_multimap_full if the flat_multimap is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(const value_type& value) ETL_PAIR<iterator, bool> insert(const value_type& value)
{ {
ETL_ASSERT(!refmap_t::full(), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(!refmap_t::full(), ETL_ERROR(flat_multimap_full));
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
iterator i_element = lower_bound(value.first); iterator i_element = lower_bound(value.first);
@ -300,7 +300,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
std::pair<iterator, bool> emplace(const value_type& value) ETL_PAIR<iterator, bool> emplace(const value_type& value)
{ {
return insert(value); return insert(value);
} }
@ -308,7 +308,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
std::pair<iterator, bool> emplace(const key_type& key, const mapped_type& value) ETL_PAIR<iterator, bool> emplace(const key_type& key, const mapped_type& value)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
@ -327,14 +327,14 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename ... Args> template <typename ... Args>
std::pair<iterator, bool> emplace(const key_type& key, Args && ... args) ETL_PAIR<iterator, bool> emplace(const key_type& key, Args && ... args)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
// Create it. // Create it.
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(std::forward<Args>(args)...); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(ETL_STD::forward<Args>(args)...);
iterator i_element = lower_bound(key); iterator i_element = lower_bound(key);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
@ -346,7 +346,7 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename T1> template <typename T1>
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1) ETL_PAIR<iterator, bool> emplace(const key_type& key, const T1& value1)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
@ -364,7 +364,7 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2> template <typename T1, typename T2>
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2) ETL_PAIR<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
@ -382,7 +382,7 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2, typename T3> template <typename T1, typename T2, typename T3>
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3) ETL_PAIR<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
@ -400,7 +400,7 @@ namespace etl
/// Emplaces a value to the map. /// Emplaces a value to the map.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2, typename T3, typename T4> template <typename T1, typename T2, typename T3, typename T4>
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4) ETL_PAIR<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
@ -423,7 +423,7 @@ namespace etl
//********************************************************************* //*********************************************************************
size_t erase(key_parameter_t key) size_t erase(key_parameter_t key)
{ {
std::pair<iterator, iterator> range = equal_range(key); ETL_PAIR<iterator, iterator> range = equal_range(key);
if (range.first == end()) if (range.first == end())
{ {
@ -431,7 +431,7 @@ namespace etl
} }
else else
{ {
size_t d = std::distance(range.first, range.second); size_t d = ETL_STD::distance(range.first, range.second);
erase(range.first, range.second); erase(range.first, range.second);
return d; return d;
} }
@ -571,7 +571,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
return refmap_t::equal_range(key); return refmap_t::equal_range(key);
} }
@ -581,7 +581,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
return refmap_t::equal_range(key); return refmap_t::equal_range(key);
} }
@ -700,7 +700,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::iflat_multimap<TKey, TMapped, TKeyCompare>& lhs, const etl::iflat_multimap<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::iflat_multimap<TKey, TMapped, TKeyCompare>& lhs, const etl::iflat_multimap<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -720,11 +720,11 @@ namespace etl
/// A flat_multimap implementation that uses a fixed size buffer. /// A flat_multimap implementation that uses a fixed size buffer.
///\tparam TKey The key type. ///\tparam TKey The key type.
///\tparam TValue The value type. ///\tparam TValue The value type.
///\tparam TCompare The type to compare keys. Default = std::less<TKey> ///\tparam TCompare The type to compare keys. Default = ETL_STD::less<TKey>
///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\tparam MAX_SIZE_ The maximum number of elements that can be stored.
///\ingroup flat_multimap ///\ingroup flat_multimap
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = std::less<TKey> > template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<TKey> >
class flat_multimap : public etl::iflat_multimap<TKey, TValue, TCompare> class flat_multimap : public etl::iflat_multimap<TKey, TValue, TCompare>
{ {
public: public:

View File

@ -57,7 +57,7 @@ namespace etl
/// Can be used as a reference type for all flat_multisets containing a specific type. /// Can be used as a reference type for all flat_multisets containing a specific type.
///\ingroup flat_multiset ///\ingroup flat_multiset
//*************************************************************************** //***************************************************************************
template <typename T, typename TKeyCompare = std::less<T> > template <typename T, typename TKeyCompare = ETL_STD::less<T> >
class iflat_multiset : private etl::ireference_flat_multiset<T, TKeyCompare> class iflat_multiset : private etl::ireference_flat_multiset<T, TKeyCompare>
{ {
private: private:
@ -80,9 +80,9 @@ namespace etl
typedef typename refset_t::iterator iterator; typedef typename refset_t::iterator iterator;
typedef typename refset_t::const_iterator const_iterator; typedef typename refset_t::const_iterator const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -209,7 +209,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multiset_full));
#endif #endif
@ -226,13 +226,13 @@ namespace etl
/// If asserts or exceptions are enabled, emits flat_multiset_full if the flat_multiset is already full. /// If asserts or exceptions are enabled, emits flat_multiset_full if the flat_multiset is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(parameter_t value) ETL_PAIR<iterator, bool> insert(parameter_t value)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
iterator i_element = std::lower_bound(begin(), end(), value, compare); iterator i_element = ETL_STD::lower_bound(begin(), end(), value, compare);
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value); ::new (pvalue) value_type(value);
@ -273,7 +273,7 @@ namespace etl
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1> template <typename T1>
std::pair<iterator, bool> emplace(parameter_t value) ETL_PAIR<iterator, bool> emplace(parameter_t value)
{ {
return insert(value); return insert(value);
} }
@ -283,25 +283,25 @@ namespace etl
//************************************************************************* //*************************************************************************
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT)
template <typename ... Args> template <typename ... Args>
std::pair<iterator, bool> emplace(Args && ... args) ETL_PAIR<iterator, bool> emplace(Args && ... args)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
// Create it. // Create it.
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(std::forward<Args>(args)...); ::new (pvalue) value_type(ETL_STD::forward<Args>(args)...);
iterator i_element = lower_bound(*pvalue); iterator i_element = lower_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue)); return ETL_PAIR<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
} }
#else #else
//************************************************************************* //*************************************************************************
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1> template <typename T1>
std::pair<iterator, bool> emplace(const T1& value1) ETL_PAIR<iterator, bool> emplace(const T1& value1)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
@ -312,14 +312,14 @@ namespace etl
iterator i_element = lower_bound(*pvalue); iterator i_element = lower_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue)); return ETL_PAIR<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
} }
//************************************************************************* //*************************************************************************
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2> template <typename T1, typename T2>
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2) ETL_PAIR<iterator, bool> emplace(const T1& value1, const T2& value2)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
@ -330,14 +330,14 @@ namespace etl
iterator i_element = lower_bound(*pvalue); iterator i_element = lower_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue)); return ETL_PAIR<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
} }
//************************************************************************* //*************************************************************************
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2, typename T3> template <typename T1, typename T2, typename T3>
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3) ETL_PAIR<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
@ -348,14 +348,14 @@ namespace etl
iterator i_element = lower_bound(*pvalue); iterator i_element = lower_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue)); return ETL_PAIR<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
} }
//************************************************************************* //*************************************************************************
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2, typename T3, typename T4> template <typename T1, typename T2, typename T3, typename T4>
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4) ETL_PAIR<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
@ -366,7 +366,7 @@ namespace etl
iterator i_element = lower_bound(*pvalue); iterator i_element = lower_bound(*pvalue);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue)); return ETL_PAIR<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
} }
#endif #endif
@ -377,7 +377,7 @@ namespace etl
//********************************************************************* //*********************************************************************
size_t erase(parameter_t key) size_t erase(parameter_t key)
{ {
std::pair<iterator, iterator> range = equal_range(key); ETL_PAIR<iterator, iterator> range = equal_range(key);
if (range.first == end()) if (range.first == end())
{ {
@ -385,7 +385,7 @@ namespace etl
} }
else else
{ {
size_t d = std::distance(range.first, range.second); size_t d = ETL_STD::distance(range.first, range.second);
erase(range.first, range.second); erase(range.first, range.second);
return d; return d;
} }
@ -525,7 +525,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(parameter_t key) ETL_PAIR<iterator, iterator> equal_range(parameter_t key)
{ {
return refset_t::equal_range(key); return refset_t::equal_range(key);
} }
@ -535,7 +535,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(parameter_t key) const
{ {
return refset_t::equal_range(key); return refset_t::equal_range(key);
} }
@ -656,7 +656,7 @@ namespace etl
template <typename T, typename TKeyCompare> template <typename T, typename TKeyCompare>
bool operator ==(const etl::iflat_multiset<T, TKeyCompare>& lhs, const etl::iflat_multiset<T, TKeyCompare>& rhs) bool operator ==(const etl::iflat_multiset<T, TKeyCompare>& lhs, const etl::iflat_multiset<T, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -675,11 +675,11 @@ namespace etl
//*************************************************************************** //***************************************************************************
/// A flat_multiset implementation that uses a fixed size buffer. /// A flat_multiset implementation that uses a fixed size buffer.
///\tparam T The value type. ///\tparam T The value type.
///\tparam TCompare The type to compare keys. Default = std::less<T> ///\tparam TCompare The type to compare keys. Default = ETL_STD::less<T>
///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\tparam MAX_SIZE_ The maximum number of elements that can be stored.
///\ingroup flat_multiset ///\ingroup flat_multiset
//*************************************************************************** //***************************************************************************
template <typename T, const size_t MAX_SIZE_, typename TCompare = std::less<T> > template <typename T, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<T> >
class flat_multiset : public etl::iflat_multiset<T, TCompare> class flat_multiset : public etl::iflat_multiset<T, TCompare>
{ {
public: public:

View File

@ -59,7 +59,7 @@ namespace etl
/// Can be used as a reference type for all flat_sets containing a specific type. /// Can be used as a reference type for all flat_sets containing a specific type.
///\ingroup flat_set ///\ingroup flat_set
//*************************************************************************** //***************************************************************************
template <typename T, typename TKeyCompare = std::less<T> > template <typename T, typename TKeyCompare = ETL_STD::less<T> >
class iflat_set : private etl::ireference_flat_set<T, TKeyCompare> class iflat_set : private etl::ireference_flat_set<T, TKeyCompare>
{ {
private: private:
@ -82,9 +82,9 @@ namespace etl
typedef typename refset_t::iterator iterator; typedef typename refset_t::iterator iterator;
typedef typename refset_t::const_iterator const_iterator; typedef typename refset_t::const_iterator const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -211,7 +211,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_set_full)); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_set_full));
#endif #endif
@ -228,11 +228,11 @@ namespace etl
/// If asserts or exceptions are enabled, emits flat_set_full if the flat_set is already full. /// If asserts or exceptions are enabled, emits flat_set_full if the flat_set is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(parameter_t value) ETL_PAIR<iterator, bool> insert(parameter_t value)
{ {
iterator i_element = lower_bound(value); iterator i_element = lower_bound(value);
std::pair<iterator, bool> result(i_element, false); ETL_PAIR<iterator, bool> result(i_element, false);
// Doesn't already exist? // Doesn't already exist?
if ((i_element == end()) || compare(value, *i_element)) if ((i_element == end()) || compare(value, *i_element))
@ -278,7 +278,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
std::pair<iterator, bool> emplace(parameter_t value) ETL_PAIR<iterator, bool> emplace(parameter_t value)
{ {
return insert(value); return insert(value);
} }
@ -288,15 +288,15 @@ namespace etl
//************************************************************************* //*************************************************************************
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT)
template <typename ... Args> template <typename ... Args>
std::pair<iterator, bool> emplace(Args && ... args) ETL_PAIR<iterator, bool> emplace(Args && ... args)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_set_full));
std::pair<iterator, bool> result; ETL_PAIR<iterator, bool> result;
// Create it. // Create it.
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(std::forward<Args>(args)...); ::new (pvalue) value_type(ETL_STD::forward<Args>(args)...);
iterator i_element = lower_bound(*pvalue); iterator i_element = lower_bound(*pvalue);
@ -311,7 +311,7 @@ namespace etl
// Destroy it. // Destroy it.
pvalue->~value_type(); pvalue->~value_type();
storage.release(pvalue); storage.release(pvalue);
result = std::pair<iterator, bool>(end(), false); result = ETL_PAIR<iterator, bool>(end(), false);
} }
return result; return result;
@ -321,11 +321,11 @@ namespace etl
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1> template <typename T1>
std::pair<iterator, bool> emplace(const T1& value1) ETL_PAIR<iterator, bool> emplace(const T1& value1)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_set_full));
std::pair<iterator, bool> result; ETL_PAIR<iterator, bool> result;
// Create it. // Create it.
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
@ -344,7 +344,7 @@ namespace etl
// Destroy it. // Destroy it.
pvalue->~value_type(); pvalue->~value_type();
storage.release(pvalue); storage.release(pvalue);
result = std::pair<iterator, bool>(end(), false); result = ETL_PAIR<iterator, bool>(end(), false);
} }
return result; return result;
@ -354,11 +354,11 @@ namespace etl
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2> template <typename T1, typename T2>
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2) ETL_PAIR<iterator, bool> emplace(const T1& value1, const T2& value2)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_set_full));
std::pair<iterator, bool> result; ETL_PAIR<iterator, bool> result;
// Create it. // Create it.
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
@ -377,7 +377,7 @@ namespace etl
// Destroy it. // Destroy it.
pvalue->~value_type(); pvalue->~value_type();
storage.release(pvalue); storage.release(pvalue);
result = std::pair<iterator, bool>(end(), false); result = ETL_PAIR<iterator, bool>(end(), false);
} }
return result; return result;
@ -387,11 +387,11 @@ namespace etl
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2, typename T3> template <typename T1, typename T2, typename T3>
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3) ETL_PAIR<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_set_full));
std::pair<iterator, bool> result; ETL_PAIR<iterator, bool> result;
// Create it. // Create it.
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
@ -410,7 +410,7 @@ namespace etl
// Destroy it. // Destroy it.
pvalue->~value_type(); pvalue->~value_type();
storage.release(pvalue); storage.release(pvalue);
result = std::pair<iterator, bool>(end(), false); result = ETL_PAIR<iterator, bool>(end(), false);
} }
return result; return result;
@ -420,11 +420,11 @@ namespace etl
/// Emplaces a value to the set. /// Emplaces a value to the set.
//************************************************************************* //*************************************************************************
template <typename T1, typename T2, typename T3, typename T4> template <typename T1, typename T2, typename T3, typename T4>
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4) ETL_PAIR<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{ {
ETL_ASSERT(!full(), ETL_ERROR(flat_set_full)); ETL_ASSERT(!full(), ETL_ERROR(flat_set_full));
std::pair<iterator, bool> result; ETL_PAIR<iterator, bool> result;
// Create it. // Create it.
value_type* pvalue = storage.allocate<value_type>(); value_type* pvalue = storage.allocate<value_type>();
@ -443,7 +443,7 @@ namespace etl
// Destroy it. // Destroy it.
pvalue->~value_type(); pvalue->~value_type();
storage.release(pvalue); storage.release(pvalue);
result = std::pair<iterator, bool>(end(), false); result = ETL_PAIR<iterator, bool>(end(), false);
} }
return result; return result;
@ -608,7 +608,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(parameter_t key) ETL_PAIR<iterator, iterator> equal_range(parameter_t key)
{ {
return refset_t::equal_range(key); return refset_t::equal_range(key);
} }
@ -618,7 +618,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(parameter_t key) const
{ {
return refset_t::upper_bound(key); return refset_t::upper_bound(key);
} }
@ -739,7 +739,7 @@ namespace etl
template <typename T, typename TKeyCompare> template <typename T, typename TKeyCompare>
bool operator ==(const etl::iflat_set<T, TKeyCompare>& lhs, const etl::iflat_set<T, TKeyCompare>& rhs) bool operator ==(const etl::iflat_set<T, TKeyCompare>& lhs, const etl::iflat_set<T, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -758,11 +758,11 @@ namespace etl
//*************************************************************************** //***************************************************************************
/// A flat_set implementation that uses a fixed size buffer. /// A flat_set implementation that uses a fixed size buffer.
///\tparam T The value type. ///\tparam T The value type.
///\tparam TCompare The type to compare keys. Default = std::less<T> ///\tparam TCompare The type to compare keys. Default = ETL_STD::less<T>
///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\tparam MAX_SIZE_ The maximum number of elements that can be stored.
///\ingroup flat_set ///\ingroup flat_set
//*************************************************************************** //***************************************************************************
template <typename T, const size_t MAX_SIZE_, typename TCompare = std::less<T> > template <typename T, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<T> >
class flat_set : public etl::iflat_set<T, TCompare> class flat_set : public etl::iflat_set<T, TCompare>
{ {
public: public:

View File

@ -50,6 +50,7 @@ SOFTWARE.
#include "nullptr.h" #include "nullptr.h"
#include "type_traits.h" #include "type_traits.h"
#include "memory.h" #include "memory.h"
#include "iterator.h"
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
#include <initializer_list> #include <initializer_list>
@ -403,7 +404,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::forward_iterator_tag, T> class iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, T>
{ {
public: public:
@ -491,7 +492,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator /// const_iterator
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::forward_iterator_tag, const T> class const_iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, const T>
{ {
public: public:
@ -571,7 +572,7 @@ namespace etl
const node_t* p_node; const node_t* p_node;
}; };
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//************************************************************************* //*************************************************************************
/// Gets the beginning of the forward_list. /// Gets the beginning of the forward_list.
@ -670,7 +671,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d >= 0, ETL_ERROR(forward_list_iterator)); ETL_ASSERT(d >= 0, ETL_ERROR(forward_list_iterator));
#endif #endif
@ -734,7 +735,7 @@ namespace etl
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
#endif #endif
data_node_t& data_node = allocate_data_node(std::move(value)); data_node_t& data_node = allocate_data_node(ETL_STD::move(value));
insert_node_after(start_node, data_node); insert_node_after(start_node, data_node);
} }
#endif #endif
@ -750,7 +751,7 @@ namespace etl
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
#endif #endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>(); data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(std::forward<Args>(args)...); ::new (&(p_data_node->value)) T(ETL_STD::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
insert_node_after(start_node, *p_data_node); insert_node_after(start_node, *p_data_node);
} }
@ -906,7 +907,7 @@ namespace etl
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>(); data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(std::forward<Args>(args)...); ::new (&(p_data_node->value)) T(ETL_STD::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
insert_node_after(*position.p_node, *p_data_node); insert_node_after(*position.p_node, *p_data_node);
@ -1000,7 +1001,7 @@ namespace etl
void insert_after(iterator position, TIterator first, TIterator last) void insert_after(iterator position, TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT((d + size()) <= MAX_SIZE, ETL_ERROR(forward_list_full)); ETL_ASSERT((d + size()) <= MAX_SIZE, ETL_ERROR(forward_list_full));
#endif #endif
@ -1140,7 +1141,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void unique() void unique()
{ {
unique(std::equal_to<T>()); unique(ETL_STD::equal_to<T>());
} }
//************************************************************************* //*************************************************************************
@ -1181,7 +1182,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void sort() void sort()
{ {
sort(std::less<T>()); sort(ETL_STD::less<T>());
} }
//************************************************************************* //*************************************************************************
@ -1385,7 +1386,7 @@ namespace etl
//************************************************************************* //*************************************************************************
iforward_list& operator = (iforward_list&& rhs) iforward_list& operator = (iforward_list&& rhs)
{ {
move_container(std::move(rhs)); move_container(ETL_STD::move(rhs));
return *this; return *this;
} }
@ -1459,7 +1460,7 @@ namespace etl
data_node_t& allocate_data_node(rvalue_reference value) data_node_t& allocate_data_node(rvalue_reference value)
{ {
data_node_t* p_node = p_node_pool->allocate<data_node_t>(); data_node_t* p_node = p_node_pool->allocate<data_node_t>();
::new (&(p_node->value)) T(std::move(value)); ::new (&(p_node->value)) T(ETL_STD::move(value));
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
return *p_node; return *p_node;
@ -1486,7 +1487,7 @@ namespace etl
{ {
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)); ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
data_node_t& data_node = this->allocate_data_node(std::move(*first++)); data_node_t& data_node = this->allocate_data_node(ETL_STD::move(*first++));
join(p_last_node, &data_node); join(p_last_node, &data_node);
data_node.next = nullptr; data_node.next = nullptr;
p_last_node = &data_node; p_last_node = &data_node;
@ -1632,7 +1633,7 @@ namespace etl
forward_list(forward_list&& other) forward_list(forward_list&& other)
: etl::iforward_list<T>(node_pool, MAX_SIZE, false) : etl::iforward_list<T>(node_pool, MAX_SIZE, false)
{ {
this->move_container(std::move(other)); this->move_container(ETL_STD::move(other));
} }
#endif #endif
@ -1685,7 +1686,7 @@ namespace etl
forward_list& operator = (forward_list&& rhs) forward_list& operator = (forward_list&& rhs)
{ {
this->move_container(std::move(rhs)); this->move_container(ETL_STD::move(rhs));
return *this; return *this;
} }
@ -1773,7 +1774,7 @@ namespace etl
typename etl::iforward_list<T>::iterator itr = other.begin(); typename etl::iforward_list<T>::iterator itr = other.begin();
while (itr != other.end()) while (itr != other.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -1830,7 +1831,7 @@ namespace etl
//************************************************************************* //*************************************************************************
forward_list& operator = (forward_list&& rhs) forward_list& operator = (forward_list&& rhs)
{ {
this->move_container(std::move(rhs)); this->move_container(ETL_STD::move(rhs));
return *this; return *this;
} }
@ -1861,7 +1862,7 @@ namespace etl
bool operator ==(const etl::iforward_list<T>& lhs, const etl::iforward_list<T>& rhs) bool operator ==(const etl::iforward_list<T>& lhs, const etl::iforward_list<T>& rhs)
{ {
return (lhs.size() == rhs.size()) && return (lhs.size() == rhs.size()) &&
std::equal(lhs.begin(), lhs.end(), rhs.begin()); ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//************************************************************************* //*************************************************************************
@ -1886,7 +1887,7 @@ namespace etl
template <typename T> template <typename T>
bool operator <(const etl::iforward_list<T>& lhs, const etl::iforward_list<T>& rhs) bool operator <(const etl::iforward_list<T>& lhs, const etl::iforward_list<T>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), return ETL_STD::lexicographical_compare(lhs.begin(),
lhs.end(), lhs.end(),
rhs.begin(), rhs.begin(),
rhs.end()); rhs.end());

View File

@ -74,7 +74,7 @@ namespace etl
template<typename TIterator> template<typename TIterator>
frame_check_sequence(TIterator begin, const TIterator end) frame_check_sequence(TIterator begin, const TIterator end)
{ {
ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported"); ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
reset(); reset();
add(begin, end); add(begin, end);
@ -96,7 +96,7 @@ namespace etl
template<typename TIterator> template<typename TIterator>
void add(TIterator begin, const TIterator end) void add(TIterator begin, const TIterator end)
{ {
ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported"); ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
while (begin != end) while (begin != end)
{ {

View File

@ -56,6 +56,8 @@ namespace etl
typedef TParameter parameter_type; ///< The type of parameter sent to the function. typedef TParameter parameter_type; ///< The type of parameter sent to the function.
virtual ~ifunction() {}
//************************************************************************* //*************************************************************************
/// The function operator that will be overridden. /// The function operator that will be overridden.
//************************************************************************* //*************************************************************************
@ -73,6 +75,8 @@ namespace etl
typedef void parameter_type; ///< The type of parameter sent to the function. typedef void parameter_type; ///< The type of parameter sent to the function.
virtual ~ifunction() {}
//************************************************************************* //*************************************************************************
/// The function operator that will be overridden. /// The function operator that will be overridden.
//************************************************************************* //*************************************************************************

View File

@ -104,7 +104,7 @@ namespace etl
protected: protected:
typedef std::pair<TKey, TValue> key_value_t; typedef ETL_PAIR<TKey, TValue> key_value_t;
bool write_through; ///< If true, the cache should write changed items back to the store immediately. If false then a flush() or destruct will be required. bool write_through; ///< If true, the cache should write changed items back to the store immediately. If false then a flush() or destruct will be required.

View File

@ -34,6 +34,7 @@ SOFTWARE.
#include "platform.h" #include "platform.h"
#include "vector.h" #include "vector.h"
#include "pool.h" #include "pool.h"
#include "iterator.h"
#include "stl/iterator.h" #include "stl/iterator.h"
#include "stl/functional.h" #include "stl/functional.h"
@ -99,7 +100,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::random_access_iterator_tag, T> class iterator : public etl::iterator<ETL_RANDOM_ACCESS_ITERATOR_TAG, T>
{ {
public: public:
@ -237,7 +238,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator. /// const_iterator.
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::random_access_iterator_tag, const T> class const_iterator : public etl::iterator<ETL_RANDOM_ACCESS_ITERATOR_TAG, const T>
{ {
public: public:
@ -362,8 +363,8 @@ namespace etl
lookup_itr_t lookup_itr; lookup_itr_t lookup_itr;
}; };
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
protected: protected:
@ -640,10 +641,10 @@ namespace etl
template <typename TIterator> template <typename TIterator>
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
ETL_STATIC_ASSERT((etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename std::iterator_traits<TIterator>::value_type>::type>::value), "Iterator type does not match container type"); ETL_STATIC_ASSERT((etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename ETL_STD::iterator_traits<TIterator>::value_type>::type>::value), "Iterator type does not match container type");
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(static_cast<size_t>(d) <= capacity(), ETL_ERROR(vector_full)); ETL_ASSERT(static_cast<size_t>(d) <= capacity(), ETL_ERROR(vector_full));
#endif #endif
@ -709,7 +710,7 @@ namespace etl
#if defined(ETL_CHECK_PUSH_POP) #if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(size() != capacity(), ETL_ERROR(vector_full)); ETL_ASSERT(size() != capacity(), ETL_ERROR(vector_full));
#endif #endif
T* p = storage.create<T>(std::move(value)); T* p = storage.create<T>(ETL_STD::move(value));
lookup.push_back(p); lookup.push_back(p);
} }
#endif #endif
@ -723,7 +724,7 @@ namespace etl
template <typename ... Args> template <typename ... Args>
void emplace_back(Args && ... args) void emplace_back(Args && ... args)
{ {
T* p = storage.create<T>(std::forward<Args>(args)...); T* p = storage.create<T>(ETL_STD::forward<Args>(args)...);
lookup.push_back(p); lookup.push_back(p);
} }
#else #else
@ -815,7 +816,7 @@ namespace etl
{ {
ETL_ASSERT(size() + 1 <= capacity(), ETL_ERROR(vector_full)); ETL_ASSERT(size() + 1 <= capacity(), ETL_ERROR(vector_full));
T* p = storage.create<T>(T(std::move(value))); T* p = storage.create<T>(T(ETL_STD::move(value)));
position = iterator(lookup.insert(position.lookup_itr, p)); position = iterator(lookup.insert(position.lookup_itr, p));
return position; return position;
@ -831,7 +832,7 @@ namespace etl
{ {
ETL_ASSERT(!full(), ETL_ERROR(vector_full)); ETL_ASSERT(!full(), ETL_ERROR(vector_full));
T* p = storage.create<T>(T(std::forward<Args>(args)...)); T* p = storage.create<T>(T(ETL_STD::forward<Args>(args)...));
position = iterator(lookup.insert(position.lookup_itr, p)); position = iterator(lookup.insert(position.lookup_itr, p));
return position; return position;
@ -914,7 +915,7 @@ namespace etl
template <class TIterator> template <class TIterator>
void insert(iterator position, TIterator first, TIterator last) void insert(iterator position, TIterator first, TIterator last)
{ {
size_t count = size_t(std::distance(first, last)); size_t count = size_t(ETL_STD::distance(first, last));
ETL_ASSERT((size() + count) <= capacity(), ETL_ERROR(vector_full)); ETL_ASSERT((size() + count) <= capacity(), ETL_ERROR(vector_full));
@ -990,7 +991,7 @@ namespace etl
iterator itr = rhs.begin(); iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
push_back(std::move(*itr)); push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -1060,7 +1061,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void sort() void sort()
{ {
sort_function(begin(), end(), std::less<T>()); sort_function(begin(), end(), ETL_STD::less<T>());
} }
//************************************************************************* //*************************************************************************
@ -1077,7 +1078,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void sort(iterator first, iterator last) void sort(iterator first, iterator last)
{ {
sort_function(first, last, std::less<T>()); sort_function(first, last, ETL_STD::less<T>());
} }
//************************************************************************* //*************************************************************************
@ -1094,7 +1095,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void stable_sort() void stable_sort()
{ {
stable_sort_function(begin(), end(), std::less<T>()); stable_sort_function(begin(), end(), ETL_STD::less<T>());
} }
//************************************************************************* //*************************************************************************
@ -1111,7 +1112,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void stable_sort(iterator first, iterator last) void stable_sort(iterator first, iterator last)
{ {
stable_sort_function(first, last, std::less<T>()); stable_sort_function(first, last, ETL_STD::less<T>());
} }
//************************************************************************* //*************************************************************************
@ -1128,7 +1129,7 @@ namespace etl
//************************************************************************* //*************************************************************************
bool is_sorted() const bool is_sorted() const
{ {
return is_sorted_function(cbegin(), cend(), std::less<T>()); return is_sorted_function(cbegin(), cend(), ETL_STD::less<T>());
} }
//************************************************************************* //*************************************************************************
@ -1145,7 +1146,7 @@ namespace etl
//************************************************************************* //*************************************************************************
bool is_sorted(const_iterator first, const_iterator last) const bool is_sorted(const_iterator first, const_iterator last) const
{ {
return is_sorted_function(first, last, std::less<T>()); return is_sorted_function(first, last, ETL_STD::less<T>());
} }
//************************************************************************* //*************************************************************************
@ -1197,7 +1198,7 @@ namespace etl
while (itr != other.end()) while (itr != other.end())
{ {
push_back(std::move(*itr)); push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -1286,7 +1287,7 @@ namespace etl
template <typename T> template <typename T>
bool operator ==(const etl::iindirect_vector<T>& lhs, const etl::iindirect_vector<T>& rhs) bool operator ==(const etl::iindirect_vector<T>& lhs, const etl::iindirect_vector<T>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -1312,7 +1313,7 @@ namespace etl
template <typename T> template <typename T>
bool operator <(const etl::iindirect_vector<T>& lhs, const etl::iindirect_vector<T>& rhs) bool operator <(const etl::iindirect_vector<T>& lhs, const etl::iindirect_vector<T>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
} }
//*************************************************************************** //***************************************************************************
@ -1449,7 +1450,7 @@ namespace etl
indirect_vector(indirect_vector&& other) indirect_vector(indirect_vector&& other)
: etl::iindirect_vector<T>(lookup_vector, storage_pool) : etl::iindirect_vector<T>(lookup_vector, storage_pool)
{ {
this->move_container(std::move(other)); this->move_container(ETL_STD::move(other));
} }
//************************************************************************* //*************************************************************************
@ -1457,7 +1458,7 @@ namespace etl
//************************************************************************* //*************************************************************************
indirect_vector& operator = (indirect_vector&& rhs) indirect_vector& operator = (indirect_vector&& rhs)
{ {
this->move_container(std::move(rhs)); this->move_container(ETL_STD::move(rhs));
return *this; return *this;
} }
@ -1577,7 +1578,7 @@ namespace etl
: etl::iindirect_vector<T>(lookup_, pool_) : etl::iindirect_vector<T>(lookup_, pool_)
{ {
ETL_ASSERT(lookup_.capacity() <= pool_.capacity(), ETL_ERROR(indirect_vector_buffer_missmatch)); ETL_ASSERT(lookup_.capacity() <= pool_.capacity(), ETL_ERROR(indirect_vector_buffer_missmatch));
this->move_container(std::move(other)); this->move_container(ETL_STD::move(other));
} }
//************************************************************************* //*************************************************************************
@ -1585,7 +1586,7 @@ namespace etl
//************************************************************************* //*************************************************************************
indirect_vector& operator = (indirect_vector&& rhs) indirect_vector& operator = (indirect_vector&& rhs)
{ {
this->move_container(std::move(rhs)); this->move_container(ETL_STD::move(rhs));
return *this; return *this;
} }

View File

@ -48,6 +48,7 @@ SOFTWARE.
#include "error_handler.h" #include "error_handler.h"
#include "intrusive_links.h" #include "intrusive_links.h"
#include "algorithm.h" #include "algorithm.h"
#include "iterator.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "20" #define ETL_FILE "20"
@ -152,7 +153,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
intmax_t d = std::distance(first, last); intmax_t d = ETL_STD::distance(first, last);
ETL_ASSERT(d >= 0, ETL_ERROR(intrusive_forward_list_iterator_exception)); ETL_ASSERT(d >= 0, ETL_ERROR(intrusive_forward_list_iterator_exception));
#endif #endif
@ -327,7 +328,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::forward_iterator_tag, value_type> class iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, value_type>
{ {
public: public:
@ -417,7 +418,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator /// const_iterator
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::forward_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -494,7 +495,7 @@ namespace etl
const value_type* p_value; const value_type* p_value;
}; };
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//************************************************************************* //*************************************************************************
/// Constructor. /// Constructor.
@ -650,7 +651,7 @@ namespace etl
{ {
if (first != end() && (first != last)) if (first != end() && (first != last))
{ {
this->current_size -= std::distance(first, last) - 1; this->current_size -= ETL_STD::distance(first, last) - 1;
link_type* p_first = first.p_value; link_type* p_first = first.p_value;
link_type* p_last = last.p_value; link_type* p_last = last.p_value;
@ -711,7 +712,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void sort() void sort()
{ {
sort(std::less<value_type>()); sort(ETL_STD::less<value_type>());
} }
//************************************************************************* //*************************************************************************
@ -957,7 +958,7 @@ namespace etl
{ {
if (&other != this) if (&other != this)
{ {
size_t n = std::distance(begin_, end_) - 1; size_t n = ETL_STD::distance(begin_, end_) - 1;
this->current_size += n; this->current_size += n;
other.current_size -= n; other.current_size -= n;
} }
@ -986,7 +987,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void merge(list_type& other) void merge(list_type& other)
{ {
merge(other, std::less<value_type>()); merge(other, ETL_STD::less<value_type>());
} }
//************************************************************************* //*************************************************************************

View File

@ -40,6 +40,7 @@ SOFTWARE.
#include "error_handler.h" #include "error_handler.h"
#include "stl/utility.h" #include "stl/utility.h"
#include "stl/algorithm.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "22" #define ETL_FILE "22"
@ -89,22 +90,22 @@ namespace etl
template <const size_t ID_> template <const size_t ID_>
struct forward_link struct forward_link
{ {
enum enum
{ {
ID = ID_, ID = ID_,
}; };
void clear() void clear()
{ {
etl_next = nullptr; etl_next = nullptr;
} }
bool is_linked() const bool is_linked() const
{ {
return etl_next != nullptr; return etl_next != nullptr;
} }
forward_link* etl_next; forward_link* etl_next;
}; };
// Reference, Reference // Reference, Reference
@ -246,29 +247,29 @@ namespace etl
template <const size_t ID_> template <const size_t ID_>
struct bidirectional_link struct bidirectional_link
{ {
enum enum
{ {
ID = ID_, ID = ID_,
}; };
void clear() void clear()
{ {
etl_previous = nullptr; etl_previous = nullptr;
etl_next = nullptr; etl_next = nullptr;
} }
bool is_linked() const bool is_linked() const
{ {
return (etl_previous != nullptr) || (etl_next != nullptr); return (etl_previous != nullptr) || (etl_next != nullptr);
} }
void reverse() void reverse()
{ {
std::swap(etl_previous, etl_next); ETL_STD::swap(etl_previous, etl_next);
} }
bidirectional_link* etl_previous; bidirectional_link* etl_previous;
bidirectional_link* etl_next; bidirectional_link* etl_next;
void unlink() void unlink()
{ {

View File

@ -45,6 +45,7 @@ SOFTWARE.
#include "intrusive_links.h" #include "intrusive_links.h"
#include "static_assert.h" #include "static_assert.h"
#include "algorithm.h" #include "algorithm.h"
#include "iterator.h"
#include "stl/algorithm.h" #include "stl/algorithm.h"
#include "stl/iterator.h" #include "stl/iterator.h"
@ -132,7 +133,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
intmax_t d = std::distance(first, last); intmax_t d = ETL_STD::distance(first, last);
ETL_ASSERT(d >= 0, ETL_ERROR(intrusive_list_iterator_exception)); ETL_ASSERT(d >= 0, ETL_ERROR(intrusive_list_iterator_exception));
#endif #endif
@ -382,7 +383,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -487,7 +488,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator /// const_iterator
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -579,7 +580,7 @@ namespace etl
const value_type* p_value; const value_type* p_value;
}; };
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//************************************************************************* //*************************************************************************
/// Constructor. /// Constructor.
@ -733,7 +734,7 @@ namespace etl
// Join the ends. // Join the ends.
etl::link<link_type>(p_first->etl_previous, p_last); etl::link<link_type>(p_first->etl_previous, p_last);
this->current_size -= std::distance(first, last); this->current_size -= ETL_STD::distance(first, last);
if (p_last == &this->terminal_link) if (p_last == &this->terminal_link)
{ {
@ -780,7 +781,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void sort() void sort()
{ {
sort(std::less<value_type>()); sort(ETL_STD::less<value_type>());
} }
//************************************************************************* //*************************************************************************
@ -1012,7 +1013,7 @@ namespace etl
{ {
if (&other != this) if (&other != this)
{ {
size_t n = std::distance(begin_, end_); size_t n = ETL_STD::distance(begin_, end_);
this->current_size += n; this->current_size += n;
other.current_size -= n; other.current_size -= n;
} }
@ -1035,7 +1036,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void merge(list_type& other) void merge(list_type& other)
{ {
merge(other, std::less<value_type>()); merge(other, ETL_STD::less<value_type>());
} }
//************************************************************************* //*************************************************************************

View File

@ -39,6 +39,7 @@ SOFTWARE.
#include "platform.h" #include "platform.h"
#include "nullptr.h" #include "nullptr.h"
#include "iterator.h"
#include "stl/iterator.h" #include "stl/iterator.h"
@ -48,7 +49,7 @@ namespace etl
/// Read write port. /// Read write port.
//*************************************************************************** //***************************************************************************
template <typename T, uintptr_t ADDRESS = 0> template <typename T, uintptr_t ADDRESS = 0>
class io_port_rw : public std::iterator<std::forward_iterator_tag, T> class io_port_rw : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, T>
{ {
public: public:
@ -128,7 +129,7 @@ namespace etl
/// Read only port. /// Read only port.
//*************************************************************************** //***************************************************************************
template <typename T, uintptr_t ADDRESS = 0> template <typename T, uintptr_t ADDRESS = 0>
class io_port_ro : public std::iterator<std::input_iterator_tag, T> class io_port_ro : public etl::iterator<ETL_INPUT_ITERATOR_TAG, T>
{ {
public: public:
@ -192,7 +193,7 @@ namespace etl
/// Write only port. /// Write only port.
//*************************************************************************** //***************************************************************************
template <typename T, uintptr_t ADDRESS = 0> template <typename T, uintptr_t ADDRESS = 0>
class io_port_wo : public std::iterator<std::output_iterator_tag, T> class io_port_wo : public etl::iterator<ETL_OUTPUT_ITERATOR_TAG, T>
{ {
public: public:
@ -256,7 +257,7 @@ namespace etl
/// Write only port with shadow register. /// Write only port with shadow register.
//*************************************************************************** //***************************************************************************
template <typename T, uintptr_t ADDRESS = 0> template <typename T, uintptr_t ADDRESS = 0>
class io_port_wos : public std::iterator<std::forward_iterator_tag, T> class io_port_wos : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, T>
{ {
public: public:
@ -335,7 +336,7 @@ namespace etl
/// Specialisation for dynamic addresses. /// Specialisation for dynamic addresses.
//*************************************************************************** //***************************************************************************
template <typename T> template <typename T>
class io_port_rw<T, 0> : public std::iterator<std::forward_iterator_tag, T> class io_port_rw<T, 0> : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, T>
{ {
public: public:
@ -446,7 +447,7 @@ namespace etl
/// Specialisation for dynamic addresses. /// Specialisation for dynamic addresses.
//*************************************************************************** //***************************************************************************
template <typename T> template <typename T>
class io_port_ro<T, 0> : public std::iterator<std::input_iterator_tag, T> class io_port_ro<T, 0> : public etl::iterator<ETL_INPUT_ITERATOR_TAG, T>
{ {
public: public:
@ -535,7 +536,7 @@ namespace etl
/// Specialisation for dynamic addresses. /// Specialisation for dynamic addresses.
//*************************************************************************** //***************************************************************************
template <typename T> template <typename T>
class io_port_wo<T, 0> : public std::iterator<std::output_iterator_tag, T> class io_port_wo<T, 0> : public etl::iterator<ETL_OUTPUT_ITERATOR_TAG, T>
{ {
public: public:
@ -630,7 +631,7 @@ namespace etl
/// Specialisation for dynamic addresses. /// Specialisation for dynamic addresses.
//*************************************************************************** //***************************************************************************
template <typename T> template <typename T>
class io_port_wos<T, 0> : public std::iterator<std::forward_iterator_tag, T> class io_port_wos<T, 0> : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, T>
{ {
public: public:
@ -639,7 +640,7 @@ namespace etl
typedef volatile T& reference; typedef volatile T& reference;
typedef volatile const T& const_reference; typedef volatile const T& const_reference;
class iterator : public std::iterator<std::bidirectional_iterator_tag, T> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, T>
{ {
typedef io_port_wos<T, 0> iop_t; typedef io_port_wos<T, 0> iop_t;

View File

@ -42,34 +42,50 @@ SOFTWARE.
namespace etl namespace etl
{ {
//***************************************************************************
/// iterator
//***************************************************************************
template <typename TCategory, typename T, typename TDistance = ptrdiff_t, typename TPointer = T* , typename TReference = T& >
struct iterator
{
typedef T value_type;
typedef TDistance difference_type;
typedef TPointer pointer;
typedef TReference reference;
typedef TCategory iterator_category;
};
//***************************************************************************
// Helper templates.
//***************************************************************************
template <typename T> template <typename T>
struct is_input_iterator struct is_input_iterator
{ {
static const bool value = etl::is_same<typename std::iterator_traits<T>::iterator_category, std::input_iterator_tag>::value; static const bool value = etl::is_same<typename ETL_STD::iterator_traits<T>::iterator_category, ETL_INPUT_ITERATOR_TAG>::value;
}; };
template <typename T> template <typename T>
struct is_output_iterator struct is_output_iterator
{ {
static const bool value = etl::is_same<typename std::iterator_traits<T>::iterator_category, std::output_iterator_tag>::value; static const bool value = etl::is_same<typename ETL_STD::iterator_traits<T>::iterator_category, ETL_OUTPUT_ITERATOR_TAG>::value;
}; };
template <typename T> template <typename T>
struct is_forward_iterator struct is_forward_iterator
{ {
static const bool value = etl::is_same<typename std::iterator_traits<T>::iterator_category, std::forward_iterator_tag>::value; static const bool value = etl::is_same<typename ETL_STD::iterator_traits<T>::iterator_category, ETL_FORWARD_ITERATOR_TAG>::value;
}; };
template <typename T> template <typename T>
struct is_bidirectional_iterator struct is_bidirectional_iterator
{ {
static const bool value = etl::is_same<typename std::iterator_traits<T>::iterator_category, std::bidirectional_iterator_tag>::value; static const bool value = etl::is_same<typename ETL_STD::iterator_traits<T>::iterator_category, ETL_BIDIRECTIONAL_ITERATOR_TAG>::value;
}; };
template <typename T> template <typename T>
struct is_random_iterator struct is_random_iterator
{ {
static const bool value = etl::is_same<typename std::iterator_traits<T>::iterator_category, std::random_access_iterator_tag>::value; static const bool value = etl::is_same<typename ETL_STD::iterator_traits<T>::iterator_category, ETL_RANDOM_ACCESS_ITERATOR_TAG>::value;
}; };
template <typename T> template <typename T>

View File

@ -50,6 +50,7 @@ SOFTWARE.
#include "type_traits.h" #include "type_traits.h"
#include "algorithm.h" #include "algorithm.h"
#include "memory.h" #include "memory.h"
#include "iterator.h"
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
#include <initializer_list> #include <initializer_list>
@ -181,7 +182,7 @@ namespace etl
//*********************************************************************** //***********************************************************************
inline void reverse() inline void reverse()
{ {
std::swap(previous, next); ETL_STD::swap(previous, next);
} }
node_t* previous; node_t* previous;
@ -481,7 +482,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, T> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, T>
{ {
public: public:
@ -582,7 +583,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator /// const_iterator
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const T> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const T>
{ {
public: public:
@ -675,10 +676,10 @@ namespace etl
const node_t* p_node; const node_t* p_node;
}; };
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//************************************************************************* //*************************************************************************
/// Gets the beginning of the list. /// Gets the beginning of the list.
@ -809,7 +810,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d >= 0, ETL_ERROR(list_iterator)); ETL_ASSERT(d >= 0, ETL_ERROR(list_iterator));
ETL_ASSERT(size_t(d) <= MAX_SIZE, ETL_ERROR(list_full)); ETL_ASSERT(size_t(d) <= MAX_SIZE, ETL_ERROR(list_full));
#endif #endif
@ -865,7 +866,7 @@ namespace etl
#if defined(ETL_CHECK_PUSH_POP) #if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full)); ETL_ASSERT(!full(), ETL_ERROR(list_full));
#endif #endif
insert_node(get_head(), allocate_data_node(std::move(value))); insert_node(get_head(), allocate_data_node(ETL_STD::move(value)));
} }
#endif #endif
@ -882,7 +883,7 @@ namespace etl
ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool));
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>(); data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(std::forward<Args>(args)...); ::new (&(p_data_node->value)) T(ETL_STD::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
insert_node(get_head(), *p_data_node); insert_node(get_head(), *p_data_node);
} }
@ -988,7 +989,7 @@ namespace etl
#if defined(ETL_CHECK_PUSH_POP) #if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full)); ETL_ASSERT(!full(), ETL_ERROR(list_full));
#endif #endif
insert_node(terminal_node, allocate_data_node(std::move(value))); insert_node(terminal_node, allocate_data_node(ETL_STD::move(value)));
} }
#endif #endif
@ -1005,7 +1006,7 @@ namespace etl
ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool));
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>(); data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(std::forward<Args>(args)...); ::new (&(p_data_node->value)) T(ETL_STD::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
insert_node(terminal_node, *p_data_node); insert_node(terminal_node, *p_data_node);
} }
@ -1100,7 +1101,7 @@ namespace etl
{ {
ETL_ASSERT(!full(), ETL_ERROR(list_full)); ETL_ASSERT(!full(), ETL_ERROR(list_full));
data_node_t& data_node = allocate_data_node(std::move(value)); data_node_t& data_node = allocate_data_node(ETL_STD::move(value));
insert_node(*position.p_node, data_node); insert_node(*position.p_node, data_node);
return iterator(data_node); return iterator(data_node);
@ -1118,7 +1119,7 @@ namespace etl
ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool));
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>(); data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(std::forward<Args>(args)...); ::new (&(p_data_node->value)) T(ETL_STD::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
insert_node(*position.p_node, *p_data_node); insert_node(*position.p_node, *p_data_node);
@ -1268,7 +1269,7 @@ namespace etl
else if (n < size()) else if (n < size())
{ {
iterator i_start = end(); iterator i_start = end();
std::advance(i_start, -difference_type(size() - n)); ETL_STD::advance(i_start, -difference_type(size() - n));
erase(i_start, end()); erase(i_start, end());
} }
// Larger? // Larger?
@ -1333,7 +1334,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void unique() void unique()
{ {
unique(std::equal_to<T>()); unique(ETL_STD::equal_to<T>());
} }
//************************************************************************* //*************************************************************************
@ -1389,7 +1390,7 @@ namespace etl
typename ilist<T>::iterator itr = other.begin(); typename ilist<T>::iterator itr = other.begin();
while (itr != other.end()) while (itr != other.end())
{ {
to = insert(to, std::move(*itr++)); to = insert(to, ETL_STD::move(*itr++));
} }
other.erase(other.begin(), other.end()); other.erase(other.begin(), other.end());
@ -1429,7 +1430,7 @@ namespace etl
else else
{ {
// From another list. // From another list.
insert(to, std::move(*from)); insert(to, ETL_STD::move(*from));
other.erase(from); other.erase(from);
} }
} }
@ -1470,7 +1471,7 @@ namespace etl
ilist::iterator itr = first; ilist::iterator itr = first;
while (itr != last) while (itr != last)
{ {
to = insert(to, std::move(*itr++)); to = insert(to, ETL_STD::move(*itr++));
++to; ++to;
} }
@ -1484,7 +1485,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void merge(ilist& other) void merge(ilist& other)
{ {
merge(other, std::less<value_type>()); merge(other, ETL_STD::less<value_type>());
} }
//************************************************************************* //*************************************************************************
@ -1541,7 +1542,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void merge(ilist&& other) void merge(ilist&& other)
{ {
merge(std::move(other), std::less<value_type>()); merge(ETL_STD::move(other), ETL_STD::less<value_type>());
} }
//************************************************************************* //*************************************************************************
@ -1576,7 +1577,7 @@ namespace etl
{ {
while ((other_begin != other_end) && (compare(*other_begin, *this_begin))) while ((other_begin != other_end) && (compare(*other_begin, *this_begin)))
{ {
insert(this_begin, std::move(*other_begin)); insert(this_begin, ETL_STD::move(*other_begin));
++other_begin; ++other_begin;
} }
} }
@ -1587,7 +1588,7 @@ namespace etl
{ {
while (other_begin != other_end) while (other_begin != other_end)
{ {
insert(this_end, std::move(*other_begin++)); insert(this_end, ETL_STD::move(*other_begin++));
} }
} }
@ -1602,7 +1603,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void sort() void sort()
{ {
sort(std::less<T>()); sort(ETL_STD::less<T>());
} }
//************************************************************************* //*************************************************************************
@ -1764,7 +1765,7 @@ namespace etl
iterator itr = rhs.begin(); iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
push_back(std::move(*itr)); push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -1916,7 +1917,7 @@ namespace etl
ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool));
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>(); data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(std::move(value)); ::new (&(p_data_node->value)) T(ETL_STD::move(value));
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
return *p_data_node; return *p_data_node;
@ -2032,7 +2033,7 @@ namespace etl
typename etl::ilist<T>::iterator itr = other.begin(); typename etl::ilist<T>::iterator itr = other.begin();
while (itr != other.end()) while (itr != other.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -2088,7 +2089,7 @@ namespace etl
typename etl::ilist<T>::iterator itr = rhs.begin(); typename etl::ilist<T>::iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -2190,7 +2191,7 @@ namespace etl
typename etl::ilist<T>::iterator itr = other.begin(); typename etl::ilist<T>::iterator itr = other.begin();
while (itr != other.end()) while (itr != other.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -2213,7 +2214,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// Construct from initializer_list. /// Construct from initializer_list.
//************************************************************************* //*************************************************************************
list(std::initializer_list<T> init, etl::ipool& node_pool) list(ETL_STD::initializer_list<T> init, etl::ipool& node_pool)
: ilist<T>(node_pool, node_pool.max_size(), true) : ilist<T>(node_pool, node_pool.max_size(), true)
{ {
this->assign(init.begin(), init.end()); this->assign(init.begin(), init.end());
@ -2246,7 +2247,7 @@ namespace etl
typename etl::ilist<T>::iterator itr = rhs.begin(); typename etl::ilist<T>::iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -2281,7 +2282,7 @@ namespace etl
template <typename T> template <typename T>
bool operator ==(const etl::ilist<T>& lhs, const etl::ilist<T>& rhs) bool operator ==(const etl::ilist<T>& lhs, const etl::ilist<T>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//************************************************************************* //*************************************************************************
@ -2306,7 +2307,7 @@ namespace etl
template <typename T> template <typename T>
bool operator <(const etl::ilist<T>& lhs, const etl::ilist<T>& rhs) bool operator <(const etl::ilist<T>& lhs, const etl::ilist<T>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), return ETL_STD::lexicographical_compare(lhs.begin(),
lhs.end(), lhs.end(),
rhs.begin(), rhs.begin(),
rhs.end()); rhs.end());

View File

@ -49,6 +49,7 @@ SOFTWARE.
#include "nullptr.h" #include "nullptr.h"
#include "type_traits.h" #include "type_traits.h"
#include "parameter_type.h" #include "parameter_type.h"
#include "iterator.h"
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
#include <initializer_list> #include <initializer_list>
@ -461,13 +462,13 @@ namespace etl
/// A templated base for all etl::map types. /// A templated base for all etl::map types.
///\ingroup map ///\ingroup map
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TMapped, typename TKeyCompare = std::less<TKey> > template <typename TKey, typename TMapped, typename TKeyCompare = ETL_STD::less<TKey> >
class imap : public etl::map_base class imap : public etl::map_base
{ {
public: public:
typedef TKey key_type; typedef TKey key_type;
typedef std::pair<const TKey, TMapped> value_type; typedef ETL_PAIR<const TKey, TMapped> value_type;
typedef TMapped mapped_type; typedef TMapped mapped_type;
typedef TKeyCompare key_compare; typedef TKeyCompare key_compare;
typedef value_type& reference; typedef value_type& reference;
@ -574,7 +575,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -695,7 +696,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator /// const_iterator
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -803,10 +804,10 @@ namespace etl
friend class const_iterator; friend class const_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//************************************************************************* //*************************************************************************
/// Gets the beginning of the map. /// Gets the beginning of the map.
@ -916,7 +917,7 @@ namespace etl
if (!i_element.p_node) if (!i_element.p_node)
{ {
// Doesn't exist, so create a new one. // Doesn't exist, so create a new one.
i_element = insert(std::make_pair(key, mapped_type())).first; i_element = insert(ETL_MAKE_PAIR(key, mapped_type())).first;
} }
return i_element->second; return i_element->second;
@ -988,9 +989,9 @@ namespace etl
/// Returns two iterators with bounding (lower bound, upper bound) the key /// Returns two iterators with bounding (lower bound, upper bound) the key
/// provided /// provided
//************************************************************************* //*************************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
return std::make_pair<iterator, iterator>( return ETL_MAKE_PAIR<iterator, iterator>(
iterator(*this, find_lower_node(root_node, key)), iterator(*this, find_lower_node(root_node, key)),
iterator(*this, find_upper_node(root_node, key))); iterator(*this, find_upper_node(root_node, key)));
} }
@ -999,9 +1000,9 @@ namespace etl
/// Returns two const iterators with bounding (lower bound, upper bound) /// Returns two const iterators with bounding (lower bound, upper bound)
/// the key provided. /// the key provided.
//************************************************************************* //*************************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
return std::make_pair<const_iterator, const_iterator>( return ETL_MAKE_PAIR<const_iterator, const_iterator>(
const_iterator(*this, find_lower_node(root_node, key)), const_iterator(*this, find_lower_node(root_node, key)),
const_iterator(*this, find_upper_node(root_node, key))); const_iterator(*this, find_upper_node(root_node, key)));
} }
@ -1092,7 +1093,7 @@ namespace etl
/// If asserts or exceptions are enabled, emits map_full if the map is already full. /// If asserts or exceptions are enabled, emits map_full if the map is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(const value_type& value) ETL_PAIR<iterator, bool> insert(const value_type& value)
{ {
// Default to no inserted node // Default to no inserted node
Node* inserted_node = nullptr; Node* inserted_node = nullptr;
@ -1108,7 +1109,7 @@ namespace etl
inserted = inserted_node == &node; inserted = inserted_node == &node;
// Insert node into tree and return iterator to new node location in tree // Insert node into tree and return iterator to new node location in tree
return std::make_pair(iterator(*this, inserted_node), inserted); return ETL_MAKE_PAIR(iterator(*this, inserted_node), inserted);
} }
//********************************************************************* //*********************************************************************
@ -2041,7 +2042,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// A templated map implementation that uses a fixed size buffer. /// A templated map implementation that uses a fixed size buffer.
//************************************************************************* //*************************************************************************
template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = std::less<TKey> > template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<TKey> >
class map : public etl::imap<TKey, TValue, TCompare> class map : public etl::imap<TKey, TValue, TCompare>
{ {
public: public:
@ -2128,7 +2129,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::imap<TKey, TMapped, TKeyCompare>& lhs, const etl::imap<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::imap<TKey, TMapped, TKeyCompare>& lhs, const etl::imap<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -2154,7 +2155,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator <(const etl::imap<TKey, TMapped, TKeyCompare>& lhs, const etl::imap<TKey, TMapped, TKeyCompare>& rhs) bool operator <(const etl::imap<TKey, TMapped, TKeyCompare>& lhs, const etl::imap<TKey, TMapped, TKeyCompare>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), return ETL_STD::lexicographical_compare(lhs.begin(),
lhs.end(), lhs.end(),
rhs.begin(), rhs.begin(),
rhs.end()); rhs.end());

View File

@ -62,10 +62,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename T> template <typename TOutputIterator, typename T>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value) uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value)
{ {
std::fill(o_begin, o_end, value); ETL_STD::fill(o_begin, o_end, value);
return o_end; return o_end;
} }
@ -75,10 +75,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename T> template <typename TOutputIterator, typename T>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value) uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value)
{ {
typedef typename std::iterator_traits<TOutputIterator>::value_type value_type; typedef typename ETL_STD::iterator_traits<TOutputIterator>::value_type value_type;
while (o_begin != o_end) while (o_begin != o_end)
{ {
@ -95,12 +95,12 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename T, typename TCounter> template <typename TOutputIterator, typename T, typename TCounter>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count) uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count)
{ {
count += int32_t(std::distance(o_begin, o_end)); count += int32_t(ETL_STD::distance(o_begin, o_end));
std::fill(o_begin, o_end, value); ETL_STD::fill(o_begin, o_end, value);
return o_end; return o_end;
} }
@ -111,10 +111,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename T, typename TCounter> template <typename TOutputIterator, typename T, typename TCounter>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count) uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count)
{ {
count += int32_t(std::distance(o_begin, o_end)); count += int32_t(ETL_STD::distance(o_begin, o_end));
etl::uninitialized_fill(o_begin, o_end, value); etl::uninitialized_fill(o_begin, o_end, value);
@ -149,10 +149,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TInputIterator, typename TOutputIterator> template <typename TInputIterator, typename TOutputIterator>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin) uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
{ {
return std::copy(i_begin, i_end, o_begin); return ETL_STD::copy(i_begin, i_end, o_begin);
} }
//***************************************************************************** //*****************************************************************************
@ -160,10 +160,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TInputIterator, typename TOutputIterator> template <typename TInputIterator, typename TOutputIterator>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin) uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin)
{ {
typedef typename std::iterator_traits<TOutputIterator>::value_type value_type; typedef typename ETL_STD::iterator_traits<TOutputIterator>::value_type value_type;
TOutputIterator o_end = o_begin; TOutputIterator o_end = o_begin;
@ -183,11 +183,11 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TInputIterator, typename TOutputIterator, typename TCounter> template <typename TInputIterator, typename TOutputIterator, typename TCounter>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count) uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
{ {
TOutputIterator o_end = std::copy(i_begin, i_end, o_begin); TOutputIterator o_end = ETL_STD::copy(i_begin, i_end, o_begin);
count += int32_t(std::distance(o_begin, o_end)); count += int32_t(ETL_STD::distance(o_begin, o_end));
return o_end; return o_end;
} }
@ -198,12 +198,12 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TInputIterator, typename TOutputIterator, typename TCounter> template <typename TInputIterator, typename TOutputIterator, typename TCounter>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count) uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
{ {
TOutputIterator o_end = etl::uninitialized_copy(i_begin, i_end, o_begin); TOutputIterator o_end = etl::uninitialized_copy(i_begin, i_end, o_begin);
count += int32_t(std::distance(o_begin, o_end)); count += int32_t(ETL_STD::distance(o_begin, o_end));
return o_end; return o_end;
} }
@ -280,7 +280,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator> template <typename TOutputIterator>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, void>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, void>::type
uninitialized_default_construct(TOutputIterator /*o_begin*/, TOutputIterator /*o_end*/) uninitialized_default_construct(TOutputIterator /*o_begin*/, TOutputIterator /*o_end*/)
{ {
} }
@ -290,10 +290,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator> template <typename TOutputIterator>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, void>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, void>::type
uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end) uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end)
{ {
typedef typename std::iterator_traits<TOutputIterator>::value_type value_type; typedef typename ETL_STD::iterator_traits<TOutputIterator>::value_type value_type;
while (o_begin != o_end) while (o_begin != o_end)
{ {
@ -308,10 +308,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename TCounter> template <typename TOutputIterator, typename TCounter>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, void>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, void>::type
uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count)
{ {
count = int32_t(std::distance(o_begin, o_end)); count = int32_t(ETL_STD::distance(o_begin, o_end));
} }
//***************************************************************************** //*****************************************************************************
@ -320,10 +320,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename TCounter> template <typename TOutputIterator, typename TCounter>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, void>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, void>::type
uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count)
{ {
count += int32_t(std::distance(o_begin, o_end)); count += int32_t(ETL_STD::distance(o_begin, o_end));
etl::uninitialized_default_construct(o_begin, o_end); etl::uninitialized_default_construct(o_begin, o_end);
} }
@ -333,7 +333,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename TSize> template <typename TOutputIterator, typename TSize>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_default_construct_n(TOutputIterator o_begin, TSize n) uninitialized_default_construct_n(TOutputIterator o_begin, TSize n)
{ {
TOutputIterator o_end = o_begin + n; TOutputIterator o_end = o_begin + n;
@ -346,7 +346,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename TSize> template <typename TOutputIterator, typename TSize>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_default_construct_n(TOutputIterator o_begin, TSize n) uninitialized_default_construct_n(TOutputIterator o_begin, TSize n)
{ {
TOutputIterator o_end = o_begin + n; TOutputIterator o_end = o_begin + n;
@ -362,7 +362,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename TSize, typename TCounter> template <typename TOutputIterator, typename TSize, typename TCounter>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_default_construct_n(TOutputIterator o_begin, TSize n, TCounter& count) uninitialized_default_construct_n(TOutputIterator o_begin, TSize n, TCounter& count)
{ {
TOutputIterator o_end = o_begin + n; TOutputIterator o_end = o_begin + n;
@ -378,7 +378,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator, typename TSize, typename TCounter> template <typename TOutputIterator, typename TSize, typename TCounter>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_default_construct_n(TOutputIterator o_begin, TSize n, TCounter& count) uninitialized_default_construct_n(TOutputIterator o_begin, TSize n, TCounter& count)
{ {
TOutputIterator o_end = o_begin + n; TOutputIterator o_end = o_begin + n;
@ -429,7 +429,7 @@ namespace etl
template <typename T> template <typename T>
void create_copy_at(T* p, T&& value) void create_copy_at(T* p, T&& value)
{ {
::new (p) T(std::move(value)); ::new (p) T(ETL_STD::move(value));
} }
#endif #endif
@ -486,7 +486,7 @@ namespace etl
template <typename T> template <typename T>
T& make_copy_at(T* p, T&& other) T& make_copy_at(T* p, T&& other)
{ {
::new (p) T(std::move(other)); ::new (p) T(ETL_STD::move(other));
return *reinterpret_cast<T*>(p); return *reinterpret_cast<T*>(p);
} }
#endif #endif
@ -522,7 +522,7 @@ namespace etl
template <typename T, typename TParameter> template <typename T, typename TParameter>
T& make_value_at(T* p, TParameter&& value) T& make_value_at(T* p, TParameter&& value)
{ {
::new (p) T(std::move(value)); ::new (p) T(ETL_STD::move(value));
return *reinterpret_cast<T*>(p); return *reinterpret_cast<T*>(p);
} }
#endif #endif
@ -544,12 +544,12 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator> template <typename TOutputIterator>
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, void>::type typename etl::enable_if<etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, void>::type
uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end) uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end)
{ {
typedef typename std::iterator_traits<TOutputIterator>::value_type value_type; typedef typename ETL_STD::iterator_traits<TOutputIterator>::value_type value_type;
std::fill(o_begin, o_end, value_type()); ETL_STD::fill(o_begin, o_end, value_type());
} }
//***************************************************************************** //*****************************************************************************
@ -557,10 +557,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TOutputIterator> template <typename TOutputIterator>
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, void>::type typename etl::enable_if<!etl::is_trivially_constructible<typename ETL_STD::iterator_traits<TOutputIterator>::value_type>::value, void>::type
uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end) uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end)
{ {
typedef typename std::iterator_traits<TOutputIterator>::value_type value_type; typedef typename ETL_STD::iterator_traits<TOutputIterator>::value_type value_type;
while (o_begin != o_end) while (o_begin != o_end)
{ {
@ -577,7 +577,7 @@ namespace etl
template <typename TOutputIterator, typename TCounter> template <typename TOutputIterator, typename TCounter>
void uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) void uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count)
{ {
count += int32_t(std::distance(o_begin, o_end)); count += int32_t(ETL_STD::distance(o_begin, o_end));
etl::uninitialized_value_construct(o_begin, o_end); etl::uninitialized_value_construct(o_begin, o_end);
} }
@ -664,7 +664,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TIterator> template <typename TIterator>
typename etl::enable_if<etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, void>::type typename etl::enable_if<etl::is_trivially_destructible<typename ETL_STD::iterator_traits<TIterator>::value_type>::value, void>::type
destroy(TIterator /*i_begin*/, TIterator /*i_end*/) destroy(TIterator /*i_begin*/, TIterator /*i_end*/)
{ {
} }
@ -674,7 +674,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TIterator> template <typename TIterator>
typename etl::enable_if<!etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, void>::type typename etl::enable_if<!etl::is_trivially_destructible<typename ETL_STD::iterator_traits<TIterator>::value_type>::value, void>::type
destroy(TIterator i_begin, TIterator i_end) destroy(TIterator i_begin, TIterator i_end)
{ {
while (i_begin != i_end) while (i_begin != i_end)
@ -690,10 +690,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TIterator, typename TCounter> template <typename TIterator, typename TCounter>
typename etl::enable_if<etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, void>::type typename etl::enable_if<etl::is_trivially_destructible<typename ETL_STD::iterator_traits<TIterator>::value_type>::value, void>::type
destroy(TIterator i_begin, TIterator i_end, TCounter& count) destroy(TIterator i_begin, TIterator i_end, TCounter& count)
{ {
count -= int32_t(std::distance(i_begin, i_end)); count -= int32_t(ETL_STD::distance(i_begin, i_end));
} }
//***************************************************************************** //*****************************************************************************
@ -702,10 +702,10 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TIterator, typename TCounter> template <typename TIterator, typename TCounter>
typename etl::enable_if<!etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, void>::type typename etl::enable_if<!etl::is_trivially_destructible<typename ETL_STD::iterator_traits<TIterator>::value_type>::value, void>::type
destroy(TIterator i_begin, TIterator i_end, TCounter& count) destroy(TIterator i_begin, TIterator i_end, TCounter& count)
{ {
count -= int32_t(std::distance(i_begin, i_end)); count -= int32_t(ETL_STD::distance(i_begin, i_end));
while (i_begin != i_end) while (i_begin != i_end)
{ {
@ -719,7 +719,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TIterator, typename TSize> template <typename TIterator, typename TSize>
typename etl::enable_if<etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, TIterator>::type typename etl::enable_if<etl::is_trivially_destructible<typename ETL_STD::iterator_traits<TIterator>::value_type>::value, TIterator>::type
destroy_n(TIterator i_begin, TSize n) destroy_n(TIterator i_begin, TSize n)
{ {
return i_begin + n; return i_begin + n;
@ -730,7 +730,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TIterator, typename TSize> template <typename TIterator, typename TSize>
typename etl::enable_if<!etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, TIterator>::type typename etl::enable_if<!etl::is_trivially_destructible<typename ETL_STD::iterator_traits<TIterator>::value_type>::value, TIterator>::type
destroy_n(TIterator i_begin, TSize n) destroy_n(TIterator i_begin, TSize n)
{ {
while (n > 0) while (n > 0)
@ -749,7 +749,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TIterator, typename TSize, typename TCounter> template <typename TIterator, typename TSize, typename TCounter>
typename etl::enable_if<etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, TIterator>::type typename etl::enable_if<etl::is_trivially_destructible<typename ETL_STD::iterator_traits<TIterator>::value_type>::value, TIterator>::type
destroy_n(TIterator i_begin, TSize n, TCounter& count) destroy_n(TIterator i_begin, TSize n, TCounter& count)
{ {
count -= n; count -= n;
@ -762,7 +762,7 @@ namespace etl
///\ingroup memory ///\ingroup memory
//***************************************************************************** //*****************************************************************************
template <typename TIterator, typename TSize, typename TCounter> template <typename TIterator, typename TSize, typename TCounter>
typename etl::enable_if<!etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, TIterator>::type typename etl::enable_if<!etl::is_trivially_destructible<typename ETL_STD::iterator_traits<TIterator>::value_type>::value, TIterator>::type
destroy_n(TIterator i_begin, TSize n, TCounter& count) destroy_n(TIterator i_begin, TSize n, TCounter& count)
{ {
count -= n; count -= n;
@ -911,7 +911,7 @@ namespace etl
void swap(unique_ptr& value) void swap(unique_ptr& value)
{ {
std::swap(p, value.p); ETL_STD::swap(p, value.p);
} }
ETL_CONSTEXPR operator bool() const ETL_CONSTEXPR operator bool() const
@ -1045,7 +1045,7 @@ namespace etl
void swap(unique_ptr& v) void swap(unique_ptr& v)
{ {
std::swap(p, v.p); ETL_STD::swap(p, v.p);
} }
ETL_CONSTEXPR operator bool() const ETL_CONSTEXPR operator bool() const
@ -1159,7 +1159,7 @@ namespace etl
template <typename T> template <typename T>
void memory_clear_range(volatile T* begin, volatile T* end) void memory_clear_range(volatile T* begin, volatile T* end)
{ {
const size_t n = static_cast<size_t>(std::distance(begin, end)); const size_t n = static_cast<size_t>(ETL_STD::distance(begin, end));
memory_clear_range(begin, n); memory_clear_range(begin, n);
} }
@ -1217,7 +1217,7 @@ namespace etl
template <typename T> template <typename T>
void memory_set_range(volatile T* begin, volatile T* end, const char value) void memory_set_range(volatile T* begin, volatile T* end, const char value)
{ {
const size_t n = static_cast<size_t>(std::distance(begin, end)); const size_t n = static_cast<size_t>(ETL_STD::distance(begin, end));
memory_set_range(begin, n, value); memory_set_range(begin, n, value);
} }

View File

@ -102,7 +102,7 @@ namespace etl
if (ok) if (ok)
{ {
router_list_t::iterator irouter = std::upper_bound(router_list.begin(), router_list_t::iterator irouter = ETL_STD::upper_bound(router_list.begin(),
router_list.end(), router_list.end(),
router.get_message_router_id(), router.get_message_router_id(),
compare_router_id()); compare_router_id());
@ -125,10 +125,10 @@ namespace etl
} }
else else
{ {
std::pair<router_list_t::iterator, router_list_t::iterator> range = std::equal_range(router_list.begin(), ETL_PAIR<router_list_t::iterator, router_list_t::iterator> range = ETL_STD::equal_range(router_list.begin(),
router_list.end(), router_list.end(),
id, id,
compare_router_id()); compare_router_id());
router_list.erase(range.first, range.second); router_list.erase(range.first, range.second);
} }
@ -137,7 +137,7 @@ namespace etl
//******************************************* //*******************************************
void unsubscribe(etl::imessage_router& router) void unsubscribe(etl::imessage_router& router)
{ {
router_list_t::iterator irouter = std::find(router_list.begin(), router_list_t::iterator irouter = ETL_STD::find(router_list.begin(),
router_list.end(), router_list.end(),
&router); &router);
@ -212,7 +212,7 @@ namespace etl
router_list_t::iterator irouter = router_list.begin(); router_list_t::iterator irouter = router_list.begin();
// Find routers with the id. // Find routers with the id.
std::pair<router_list_t::iterator, router_list_t::iterator> range = std::equal_range(router_list.begin(), ETL_PAIR<router_list_t::iterator, router_list_t::iterator> range = ETL_STD::equal_range(router_list.begin(),
router_list.end(), router_list.end(),
destination_router_id, destination_router_id,
compare_router_id()); compare_router_id());
@ -230,7 +230,7 @@ namespace etl
// Do any message buses. // Do any message buses.
// These are always at the end of the list. // These are always at the end of the list.
irouter = std::lower_bound(router_list.begin(), irouter = ETL_STD::lower_bound(router_list.begin(),
router_list.end(), router_list.end(),
etl::imessage_bus::MESSAGE_BUS, etl::imessage_bus::MESSAGE_BUS,
compare_router_id()); compare_router_id());

View File

@ -45,28 +45,37 @@ SOFTWARE.
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "44" #define ETL_FILE "44"
#if !defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK) #if defined(ETL_IN_UNIT_TEST) && defined(ETL_NO_STL)
#error ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK or ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK not defined #define ETL_DISABLE_TIMER_UPDATES
#endif #define ETL_ENABLE_TIMER_UPDATES
#define ETL_TIMER_UPDATES_ENABLED true
#if defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) && defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK) #undef ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK
#error Only define one of ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK or ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK #undef ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK
#endif #else
#if !defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK)
#if defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) #error ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK or ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK not defined
#define ETL_DISABLE_TIMER_UPDATES (++process_semaphore)
#define ETL_ENABLE_TIMER_UPDATES (--process_semaphore)
#define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0)
#endif
#if defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK)
#if !defined(ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS) || !defined(ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS)
#error ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS and/or ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS not defined
#endif #endif
#define ETL_DISABLE_TIMER_UPDATES (ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS) #if defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK) && defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK)
#define ETL_ENABLE_TIMER_UPDATES (ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS) #error Only define one of ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK or ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK
#define ETL_TIMER_UPDATES_ENABLED true #endif
#if defined(ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK)
#define ETL_DISABLE_TIMER_UPDATES (++process_semaphore)
#define ETL_ENABLE_TIMER_UPDATES (--process_semaphore)
#define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0)
#endif
#if defined(ETL_MESSAGE_TIMER_USE_INTERRUPT_LOCK)
#if !defined(ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS) || !defined(ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS)
#error ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS and/or ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS not defined
#endif
#define ETL_DISABLE_TIMER_UPDATES (ETL_MESSAGE_TIMER_DISABLE_INTERRUPTS)
#define ETL_ENABLE_TIMER_UPDATES (ETL_MESSAGE_TIMER_ENABLE_INTERRUPTS)
#define ETL_TIMER_UPDATES_ENABLED true
#endif
#endif #endif
namespace etl namespace etl

View File

@ -1,143 +0,0 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
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.
******************************************************************************/
/******************************************************************************
Copyright (C) 2017 by Sergey A Kryukov: derived work
http://www.SAKryukov.org
http://www.codeproject.com/Members/SAKryukov
Based on original work by Sergey Ryazanov:
"The Impossibly Fast C++ Delegates", 18 Jul 2005
https://www.codeproject.com/articles/11015/the-impossibly-fast-c-delegates
MIT license:
http://en.wikipedia.org/wiki/MIT_License
Original publication: https://www.codeproject.com/Articles/1170503/The-Impossibly-Fast-Cplusplus-Delegates-Fixed
******************************************************************************/
//#pragma once
//#include "delegate.h"
//#include <list>
//#include <functional>
//
//namespace SA {
//
// template<typename RET, typename ...PARAMS>
// class multicast_delegate<RET(PARAMS...)> final : private delegate_base<RET(PARAMS...)> {
// public:
//
// multicast_delegate() = default;
// ~multicast_delegate() {
// for (auto& element : invocationList) delete element;
// invocationList.clear();
// } //~multicast_delegate
//
// bool isNull() const { return invocationList.size() < 1; }
// bool operator ==(void* ptr) const {
// return (ptr == nullptr) && this->isNull();
// } //operator ==
// bool operator !=(void* ptr) const {
// return (ptr != nullptr) || (!this->isNull());
// } //operator !=
//
// size_t size() const { return invocationList.size(); }
//
// multicast_delegate& operator =(const multicast_delegate&) = delete;
// multicast_delegate(const multicast_delegate&) = delete;
//
// bool operator ==(const multicast_delegate& another) const {
// if (invocationList.size() != another.invocationList.size()) return false;
// auto anotherIt = another.invocationList.begin();
// for (auto it = invocationList.begin(); it != invocationList.end(); ++it)
// if (**it != **anotherIt) return false;
// return true;
// } //==
// bool operator !=(const multicast_delegate& another) const { return !(*this == another); }
//
// bool operator ==(const delegate<RET(PARAMS...)>& another) const {
// if (isNull() && another.isNull()) return true;
// if (another.isNull() || (size() != 1)) return false;
// return (another.invocation == **invocationList.begin());
// } //==
// bool operator !=(const delegate<RET(PARAMS...)>& another) const { return !(*this == another); }
//
// multicast_delegate& operator +=(const multicast_delegate& another) {
// for (auto& item : another.invocationList) // clone, not copy; flattens hierarchy:
// this->invocationList.push_back(new typename delegate_base<RET(PARAMS...)>::InvocationElement(item->object, item->stub));
// return *this;
// } //operator +=
//
// template <typename LAMBDA> // template instantiation is not neededm, will be deduced/inferred:
// multicast_delegate& operator +=(const LAMBDA & lambda) {
// delegate<RET(PARAMS...)> d = delegate<RET(PARAMS...)>::template create<LAMBDA>(lambda);
// return *this += d;
// } //operator +=
//
// multicast_delegate& operator +=(const delegate<RET(PARAMS...)>& another) {
// if (another.isNull()) return *this;
// this->invocationList.push_back(new typename delegate_base<RET(PARAMS...)>::InvocationElement(another.invocation.object, another.invocation.stub));
// return *this;
// } //operator +=
//
// // will work even if RET is void, return values are ignored:
// // (for handling return values, see operator(..., handler))
// void operator()(PARAMS... arg) const {
// for (auto& item : invocationList)
// (*(item->stub))(item->object, arg...);
// } //operator()
//
// template<typename HANDLER>
// void operator()(PARAMS... arg, HANDLER handler) const {
// size_t index = 0;
// for (auto& item : invocationList) {
// RET value = (*(item->stub))(item->object, arg...);
// handler(index, &value);
// ++index;
// } //loop
// } //operator()
//
// void operator()(PARAMS... arg, delegate<void(size_t, RET*)> handler) const {
// operator()<decltype(handler)>(arg..., handler);
// } //operator()
// void operator()(PARAMS... arg, std::function<void(size_t, RET*)> handler) const {
// operator()<decltype(handler)>(arg..., handler);
// } //operator()
//
// private:
//
// std::list<typename delegate_base<RET(PARAMS...)>::InvocationElement *> invocationList;
//
// }; //class multicast_delegate
//
//} /* namespace SA */
//

View File

@ -49,6 +49,7 @@ SOFTWARE.
#include "nullptr.h" #include "nullptr.h"
#include "type_traits.h" #include "type_traits.h"
#include "parameter_type.h" #include "parameter_type.h"
#include "iterator.h"
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL) #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
#include <initializer_list> #include <initializer_list>
@ -623,12 +624,12 @@ namespace etl
/// A templated base for all etl::multimap types. /// A templated base for all etl::multimap types.
///\ingroup map ///\ingroup map
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TMapped, typename TKeyCompare = std::less<TKey> > template <typename TKey, typename TMapped, typename TKeyCompare = ETL_STD::less<TKey> >
class imultimap : public etl::multimap_base class imultimap : public etl::multimap_base
{ {
public: public:
typedef std::pair<const TKey, TMapped> value_type; typedef ETL_PAIR<const TKey, TMapped> value_type;
typedef const TKey key_type; typedef const TKey key_type;
typedef TMapped mapped_type; typedef TMapped mapped_type;
typedef TKeyCompare key_compare; typedef TKeyCompare key_compare;
@ -732,7 +733,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -852,7 +853,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator /// const_iterator
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -959,10 +960,10 @@ namespace etl
}; };
friend class const_iterator; friend class const_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//************************************************************************* //*************************************************************************
/// Gets the beginning of the multimap. /// Gets the beginning of the multimap.
@ -1096,9 +1097,9 @@ namespace etl
/// Returns two iterators with bounding (lower bound, upper bound) the key /// Returns two iterators with bounding (lower bound, upper bound) the key
/// provided /// provided
//************************************************************************* //*************************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
return std::make_pair<iterator, iterator>( return ETL_MAKE_PAIR<iterator, iterator>(
iterator(*this, find_lower_node(root_node, key)), iterator(*this, find_lower_node(root_node, key)),
iterator(*this, find_upper_node(root_node, key))); iterator(*this, find_upper_node(root_node, key)));
} }
@ -1107,9 +1108,9 @@ namespace etl
/// Returns two const iterators with bounding (lower bound, upper bound) /// Returns two const iterators with bounding (lower bound, upper bound)
/// the key provided. /// the key provided.
//************************************************************************* //*************************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
return std::make_pair<const_iterator, const_iterator>( return ETL_MAKE_PAIR<const_iterator, const_iterator>(
const_iterator(*this, find_lower_node(root_node, key)), const_iterator(*this, find_lower_node(root_node, key)),
const_iterator(*this, find_upper_node(root_node, key))); const_iterator(*this, find_upper_node(root_node, key)));
} }
@ -1930,7 +1931,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// A templated multimap implementation that uses a fixed size buffer. /// A templated multimap implementation that uses a fixed size buffer.
//************************************************************************* //*************************************************************************
template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = std::less<TKey> > template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<TKey> >
class multimap : public etl::imultimap<TKey, TValue, TCompare> class multimap : public etl::imultimap<TKey, TValue, TCompare>
{ {
public: public:
@ -2017,7 +2018,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::imultimap<TKey, TMapped, TKeyCompare>& lhs, const etl::imultimap<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::imultimap<TKey, TMapped, TKeyCompare>& lhs, const etl::imultimap<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -2043,7 +2044,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator <(const etl::imultimap<TKey, TMapped, TKeyCompare>& lhs, const etl::imultimap<TKey, TMapped, TKeyCompare>& rhs) bool operator <(const etl::imultimap<TKey, TMapped, TKeyCompare>& lhs, const etl::imultimap<TKey, TMapped, TKeyCompare>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), return ETL_STD::lexicographical_compare(lhs.begin(),
lhs.end(), lhs.end(),
rhs.begin(), rhs.begin(),
rhs.end()); rhs.end());

View File

@ -623,7 +623,7 @@ namespace etl
/// A templated base for all etl::multiset types. /// A templated base for all etl::multiset types.
///\ingroup set ///\ingroup set
//*************************************************************************** //***************************************************************************
template <typename T, typename TCompare = std::less<T> > template <typename T, typename TCompare = ETL_STD::less<T> >
class imultiset : public etl::multiset_base class imultiset : public etl::multiset_base
{ {
public: public:
@ -713,7 +713,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -818,7 +818,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator /// const_iterator
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -925,10 +925,10 @@ namespace etl
}; };
friend class const_iterator; friend class const_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//************************************************************************* //*************************************************************************
/// Gets the beginning of the multiset. /// Gets the beginning of the multiset.
@ -1062,9 +1062,9 @@ namespace etl
/// Returns two iterators with bounding (lower bound, upper bound) the key /// Returns two iterators with bounding (lower bound, upper bound) the key
/// provided /// provided
//************************************************************************* //*************************************************************************
std::pair<iterator, iterator> equal_range(const value_type& key) ETL_PAIR<iterator, iterator> equal_range(const value_type& key)
{ {
return std::make_pair<iterator, iterator>( return ETL_MAKE_PAIR<iterator, iterator>(
iterator(*this, find_lower_node(root_node, key)), iterator(*this, find_lower_node(root_node, key)),
iterator(*this, find_upper_node(root_node, key))); iterator(*this, find_upper_node(root_node, key)));
} }
@ -1073,9 +1073,9 @@ namespace etl
/// Returns two const iterators with bounding (lower bound, upper bound) /// Returns two const iterators with bounding (lower bound, upper bound)
/// the key provided. /// the key provided.
//************************************************************************* //*************************************************************************
std::pair<const_iterator, const_iterator> equal_range(const value_type& key) const ETL_PAIR<const_iterator, const_iterator> equal_range(const value_type& key) const
{ {
return std::make_pair<const_iterator, const_iterator>( return ETL_MAKE_PAIR<const_iterator, const_iterator>(
const_iterator(*this, find_lower_node(root_node, key)), const_iterator(*this, find_lower_node(root_node, key)),
const_iterator(*this, find_upper_node(root_node, key))); const_iterator(*this, find_upper_node(root_node, key)));
} }
@ -1895,7 +1895,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// A templated multiset implementation that uses a fixed size buffer. /// A templated multiset implementation that uses a fixed size buffer.
//************************************************************************* //*************************************************************************
template <typename T, const size_t MAX_SIZE_, typename TCompare = std::less<T> > template <typename T, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<T> >
class multiset : public etl::imultiset<T, TCompare> class multiset : public etl::imultiset<T, TCompare>
{ {
public: public:
@ -1982,7 +1982,7 @@ namespace etl
template <typename T, typename TCompare> template <typename T, typename TCompare>
bool operator ==(const etl::imultiset<T, TCompare>& lhs, const etl::imultiset<T, TCompare>& rhs) bool operator ==(const etl::imultiset<T, TCompare>& lhs, const etl::imultiset<T, TCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -2008,7 +2008,7 @@ namespace etl
template <typename T, typename TCompare> template <typename T, typename TCompare>
bool operator <(const etl::imultiset<T, TCompare>& lhs, const etl::imultiset<T, TCompare>& rhs) bool operator <(const etl::imultiset<T, TCompare>& lhs, const etl::imultiset<T, TCompare>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), return ETL_STD::lexicographical_compare(lhs.begin(),
lhs.end(), lhs.end(),
rhs.begin(), rhs.begin(),
rhs.end()); rhs.end());

View File

@ -81,7 +81,7 @@ namespace etl
murmur3(TIterator begin, const TIterator end, value_type seed_ = 0) murmur3(TIterator begin, const TIterator end, value_type seed_ = 0)
: seed(seed_) : seed(seed_)
{ {
ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Incompatible type"); ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits<TIterator>::value_type) == 1, "Incompatible type");
reset(); reset();
while (begin != end) while (begin != end)
@ -119,7 +119,7 @@ namespace etl
template<typename TIterator> template<typename TIterator>
void add(TIterator begin, const TIterator end) void add(TIterator begin, const TIterator end)
{ {
ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Incompatible type"); ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits<TIterator>::value_type) == 1, "Incompatible type");
ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised)); ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised));
while (begin != end) while (begin != end)

View File

@ -115,9 +115,9 @@ namespace etl
void add_observer(TObserver& observer) void add_observer(TObserver& observer)
{ {
// See if we already have it in our list. // See if we already have it in our list.
typename Observer_List::const_iterator i_observer = std::find(observer_list.begin(), typename Observer_List::const_iterator i_observer = ETL_STD::find(observer_list.begin(),
observer_list.end(), observer_list.end(),
&observer); &observer);
// Not there? // Not there?
if (i_observer == observer_list.end()) if (i_observer == observer_list.end())
@ -138,9 +138,9 @@ namespace etl
bool remove_observer(TObserver& observer) bool remove_observer(TObserver& observer)
{ {
// See if we have it in our list. // See if we have it in our list.
typename Observer_List::iterator i_observer = std::find(observer_list.begin(), typename Observer_List::iterator i_observer = ETL_STD::find(observer_list.begin(),
observer_list.end(), observer_list.end(),
&observer); &observer);
// Found it? // Found it?
if (i_observer != observer_list.end()) if (i_observer != observer_list.end())

View File

@ -343,7 +343,7 @@ namespace etl
storage.template get_reference<T>().~T(); storage.template get_reference<T>().~T();
} }
::new (storage.template get_address<T>()) T(std::forward<Args>(args)...); ::new (storage.template get_address<T>()) T(ETL_STD::forward<Args>(args)...);
valid = true; valid = true;
} }
#else #else

View File

@ -81,7 +81,7 @@ namespace etl
pearson(TIterator begin, const TIterator end) pearson(TIterator begin, const TIterator end)
: first(true) : first(true)
{ {
ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported"); ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
reset(); reset();
add(begin, end); add(begin, end);
@ -103,7 +103,7 @@ namespace etl
template<typename TIterator> template<typename TIterator>
void add(TIterator begin, const TIterator end) void add(TIterator begin, const TIterator end)
{ {
ETL_STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported"); ETL_STATIC_ASSERT(sizeof(typename ETL_STD::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
while (begin != end) while (begin != end)
{ {

View File

@ -64,11 +64,6 @@ SOFTWARE.
// The macros below are dependent on the profile. // The macros below are dependent on the profile.
#if defined(ETL_COMPILER_MICROSOFT)
// Disable warning of deprecated std::iterator.
#pragma warning(disable : 4996)
#endif
#if defined(ETL_COMPILER_GCC) #if defined(ETL_COMPILER_GCC)
#define ETL_COMPILER_VERSION __GNUC__ #define ETL_COMPILER_VERSION __GNUC__
#define ETL_COMPILER_FULL_VERSION ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) #define ETL_COMPILER_FULL_VERSION ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__)
@ -79,13 +74,17 @@ SOFTWARE.
#if ETL_CPP11_SUPPORTED #if ETL_CPP11_SUPPORTED
#define ETL_CONSTEXPR constexpr #define ETL_CONSTEXPR constexpr
#define ETL_CONST constexpr
#else #else
#define ETL_CONSTEXPR #define ETL_CONSTEXPR
#define ETL_CONST const
#endif #endif
#if ETL_CPP17_SUPPORTED #if ETL_CPP17_SUPPORTED
#define ETL_CONSTEXPR17 constexpr
#define ETL_IF_CONSTEXPR constexpr #define ETL_IF_CONSTEXPR constexpr
#else #else
#define ETL_CONSTEXPR17
#define ETL_IF_CONSTEXPR #define ETL_IF_CONSTEXPR
#endif #endif
@ -98,9 +97,17 @@ SOFTWARE.
#if ETL_CPP11_SUPPORTED #if ETL_CPP11_SUPPORTED
#define ETL_NOEXCEPT noexcept #define ETL_NOEXCEPT noexcept
#define ETL_NOEXCEPT_EXPR(expression) noexcept(expression) #define ETL_NOEXCEPT_EXPR(expression) noexcept(expression)
#define ETL_NODISCARD [[nodiscard]]
#else #else
#define ETL_NOEXCEPT #define ETL_NOEXCEPT
#define ETL_NOEXCEPT_EXPR(expression) #define ETL_NOEXCEPT_EXPR(expression)
#define ETL_NODISCARD
#endif
#if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR)
#define ETL_EXPLICIT_STRING_FROM_CHAR explicit
#else
#define ETL_EXPLICIT_STRING_FROM_CHAR
#endif #endif
#if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR) #if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR)

View File

@ -138,7 +138,7 @@ namespace etl
return reinterpret_cast<T*>(allocate_item()); return reinterpret_cast<T*>(allocate_item());
} }
#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) #if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT)
//************************************************************************* //*************************************************************************
/// Allocate storage for an object from the pool and create default. /// Allocate storage for an object from the pool and create default.
/// If asserts or exceptions are enabled and there are no more free items an /// If asserts or exceptions are enabled and there are no more free items an
@ -224,7 +224,7 @@ namespace etl
if (p) if (p)
{ {
::new (p) T(std::forward<Args>(args)...); ::new (p) T(ETL_STD::forward<Args>(args)...);
} }
return p; return p;
@ -497,7 +497,7 @@ namespace etl
return ipool::allocate<U>(); return ipool::allocate<U>();
} }
#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) #if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT)
//************************************************************************* //*************************************************************************
/// Allocate storage for an object from the pool and create with default. /// Allocate storage for an object from the pool and create with default.
/// If asserts or exceptions are enabled and there are no more free items an /// If asserts or exceptions are enabled and there are no more free items an
@ -571,7 +571,7 @@ namespace etl
{ {
ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= ALIGNMENT_, "Type has incompatible alignment"); ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= ALIGNMENT_, "Type has incompatible alignment");
ETL_STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); ETL_STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool");
return ipool::create<U>(std::forward<Args>(args)...); return ipool::create<U>(ETL_STD::forward<Args>(args)...);
} }
#endif #endif
@ -648,7 +648,7 @@ namespace etl
return base_t::template allocate<U>(); return base_t::template allocate<U>();
} }
#if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT) || defined(ETL_NO_STL) #if !ETL_CPP11_SUPPORTED || ETL_POOL_CPP03_CODE || defined(ETL_STLPORT)
//************************************************************************* //*************************************************************************
/// Allocate storage for an object from the pool and create with default. /// Allocate storage for an object from the pool and create with default.
/// If asserts or exceptions are enabled and there are no more free items an /// If asserts or exceptions are enabled and there are no more free items an
@ -724,7 +724,7 @@ namespace etl
{ {
ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= ALIGNMENT, "Type has incompatible alignment"); ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= ALIGNMENT, "Type has incompatible alignment");
ETL_STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool"); ETL_STATIC_ASSERT(sizeof(U) <= TYPE_SIZE, "Type too large for pool");
return base_t::template create<U>(std::forward<Args>(args)...); return base_t::template create<U>(ETL_STD::forward<Args>(args)...);
} }
#endif #endif

View File

@ -115,7 +115,7 @@ namespace etl
/// \tparam TContainer to hold the T queue values /// \tparam TContainer to hold the T queue values
/// \tparam TCompare to use in comparing T values /// \tparam TCompare to use in comparing T values
//*************************************************************************** //***************************************************************************
template <typename T, typename TContainer, typename TCompare = std::less<T> > template <typename T, typename TContainer, typename TCompare = ETL_STD::less<T> >
class ipriority_queue class ipriority_queue
{ {
public: public:
@ -126,7 +126,7 @@ namespace etl
typedef T& reference; ///< A reference to the type used in the queue. typedef T& reference; ///< A reference to the type used in the queue.
typedef const T& const_reference; ///< A const reference to the type used in the queue. typedef const T& const_reference; ///< A const reference to the type used in the queue.
typedef typename TContainer::size_type size_type; ///< The type used for determining the size of the queue. typedef typename TContainer::size_type size_type; ///< The type used for determining the size of the queue.
typedef typename std::iterator_traits<typename TContainer::iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<typename TContainer::iterator>::difference_type difference_type;
private: private:
@ -165,7 +165,7 @@ namespace etl
// Put element at end // Put element at end
container.push_back(value); container.push_back(value);
// Make elements in container into heap // Make elements in container into heap
std::push_heap(container.begin(), container.end(), compare); ETL_STD::push_heap(container.begin(), container.end(), compare);
} }
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_PRIORITY_QUEUE_FORCE_CPP03) #if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_PRIORITY_QUEUE_FORCE_CPP03)
@ -181,9 +181,9 @@ namespace etl
ETL_ASSERT(!full(), ETL_ERROR(etl::priority_queue_full)); ETL_ASSERT(!full(), ETL_ERROR(etl::priority_queue_full));
// Put element at end // Put element at end
container.emplace_back(std::forward<Args>(args)...); container.emplace_back(ETL_STD::forward<Args>(args)...);
// Make elements in container into heap // Make elements in container into heap
std::push_heap(container.begin(), container.end(), compare); ETL_STD::push_heap(container.begin(), container.end(), compare);
} }
#else #else
//************************************************************************* //*************************************************************************
@ -200,7 +200,7 @@ namespace etl
// Put element at end // Put element at end
container.emplace_back(value1); container.emplace_back(value1);
// Make elements in container into heap // Make elements in container into heap
std::push_heap(container.begin(), container.end(), compare); ETL_STD::push_heap(container.begin(), container.end(), compare);
} }
//************************************************************************* //*************************************************************************
@ -217,7 +217,7 @@ namespace etl
// Put element at end // Put element at end
container.emplace_back(value1, value2); container.emplace_back(value1, value2);
// Make elements in container into heap // Make elements in container into heap
std::push_heap(container.begin(), container.end(), compare); ETL_STD::push_heap(container.begin(), container.end(), compare);
} }
//************************************************************************* //*************************************************************************
@ -234,7 +234,7 @@ namespace etl
// Put element at end // Put element at end
container.emplace_back(value1, value2, value3); container.emplace_back(value1, value2, value3);
// Make elements in container into heap // Make elements in container into heap
std::push_heap(container.begin(), container.end(), compare); ETL_STD::push_heap(container.begin(), container.end(), compare);
} }
//************************************************************************* //*************************************************************************
@ -251,7 +251,7 @@ namespace etl
// Put element at end // Put element at end
container.emplace_back(value1, value2, value3, value4); container.emplace_back(value1, value2, value3, value4);
// Make elements in container into heap // Make elements in container into heap
std::push_heap(container.begin(), container.end(), compare); ETL_STD::push_heap(container.begin(), container.end(), compare);
} }
#endif #endif
@ -268,14 +268,14 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d >= 0, ETL_ERROR(etl::priority_queue_iterator)); ETL_ASSERT(d >= 0, ETL_ERROR(etl::priority_queue_iterator));
ETL_ASSERT(static_cast<size_t>(d) <= max_size(), ETL_ERROR(etl::priority_queue_full)); ETL_ASSERT(static_cast<size_t>(d) <= max_size(), ETL_ERROR(etl::priority_queue_full));
#endif #endif
clear(); clear();
container.assign(first, last); container.assign(first, last);
std::make_heap(container.begin(), container.end(), compare); ETL_STD::make_heap(container.begin(), container.end(), compare);
} }
//************************************************************************* //*************************************************************************
@ -285,7 +285,7 @@ namespace etl
void pop() void pop()
{ {
// Move largest element to end // Move largest element to end
std::pop_heap(container.begin(), container.end(), compare); ETL_STD::pop_heap(container.begin(), container.end(), compare);
// Actually remove largest element at end // Actually remove largest element at end
container.pop_back(); container.pop_back();
} }
@ -386,7 +386,7 @@ namespace etl
/// \tparam T The type this queue should support. /// \tparam T The type this queue should support.
/// \tparam SIZE The maximum capacity of the queue. /// \tparam SIZE The maximum capacity of the queue.
//*************************************************************************** //***************************************************************************
template <typename T, const size_t SIZE, typename TContainer = etl::vector<T, SIZE>, typename TCompare = std::less<typename TContainer::value_type> > template <typename T, const size_t SIZE, typename TContainer = etl::vector<T, SIZE>, typename TCompare = ETL_STD::less<typename TContainer::value_type> >
class priority_queue : public etl::ipriority_queue<T, TContainer, TCompare> class priority_queue : public etl::ipriority_queue<T, TContainer, TCompare>
{ {
public: public:

View File

@ -31,15 +31,15 @@ SOFTWARE.
#ifndef ETL_STL_CHOOSE_NAMESPACE_INCLUDED #ifndef ETL_STL_CHOOSE_NAMESPACE_INCLUDED
#define ETL_STL_CHOOSE_NAMESPACE_INCLUDED #define ETL_STL_CHOOSE_NAMESPACE_INCLUDED
#include "../../platform.h" #include "../platform.h"
#if defined(ETL_IN_UNIT_TEST) #if defined(ETL_NO_STL)
#ifndef ETLSTD #ifndef ETL_STD
#define ETLSTD etlstd // Used for the unit tests. #define ETL_STD etlstd /// Namespace for the alternate STL.
#endif #endif
#else #else
#ifndef ETLSTD #ifndef ETL_STD
#define ETLSTD std // Used for normal code. #define ETL_STD std /// Namespace for conventional STL
#endif #endif
#endif #endif

View File

@ -0,0 +1,45 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
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_STL_CHOOSE_PAIR_TYPES_INCLUDED
#define ETL_STL_CHOOSE_PAIR_TYPES_INCLUDED
#include "../platform.h"
#if defined(ETL_IN_UNIT_TEST) // When in the unit tests we have to ensure that the STL and ETL are using the same definitions.
#include <utility>
#define ETL_PAIR std::pair
#define ETL_MAKE_PAIR std::make_pair
#else
#define ETL_PAIR etlstd::pair
#define ETL_MAKE_PAIR etlstd::make_pair
#endif
#endif

View File

@ -0,0 +1,51 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
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_STL_CHOOSE_TAG_TYPES_INCLUDED
#define ETL_STL_CHOOSE_TAG_TYPES_INCLUDED
#include "../platform.h"
#if defined(ETL_IN_UNIT_TEST) // When in the unit tests we have to ensure that the STL and ETL are using the same definitions.
#include <iterator>
#define ETL_INPUT_ITERATOR_TAG std::input_iterator_tag
#define ETL_OUTPUT_ITERATOR_TAG std::output_iterator_tag
#define ETL_FORWARD_ITERATOR_TAG std::forward_iterator_tag
#define ETL_BIDIRECTIONAL_ITERATOR_TAG std::bidirectional_iterator_tag
#define ETL_RANDOM_ACCESS_ITERATOR_TAG std::random_access_iterator_tag
#else
#define ETL_INPUT_ITERATOR_TAG etlstd::input_iterator_tag
#define ETL_OUTPUT_ITERATOR_TAG etlstd::output_iterator_tag
#define ETL_FORWARD_ITERATOR_TAG etlstd::forward_iterator_tag
#define ETL_BIDIRECTIONAL_ITERATOR_TAG etlstd::bidirectional_iterator_tag
#define ETL_RANDOM_ACCESS_ITERATOR_TAG etlstd::random_access_iterator_tag
#endif
#endif

View File

@ -56,10 +56,10 @@ namespace etl
typedef const value_type* const_pointer; typedef const value_type* const_pointer;
typedef value_type* iterator; typedef value_type* iterator;
typedef const value_type* const_iterator; typedef const value_type* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef size_t size_type; typedef size_t size_type;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -441,7 +441,7 @@ namespace etl
//********************************************************************* //*********************************************************************
void initialise_source_external_buffer_after_move() void initialise_source_external_buffer_after_move()
{ {
ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) ETL_SUBTRACT_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end)))
p_end = p_buffer; p_end = p_buffer;
} }
@ -451,7 +451,7 @@ namespace etl
//********************************************************************* //*********************************************************************
void initialise_destination_external_buffer_after_move() void initialise_destination_external_buffer_after_move()
{ {
ETL_ADD_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) ETL_ADD_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end)))
} }
}; };
@ -467,10 +467,10 @@ namespace etl
typedef const value_type* const_pointer; typedef const value_type* const_pointer;
typedef value_type* iterator; typedef value_type* iterator;
typedef const value_type* const_iterator; typedef const value_type* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef size_t size_type; typedef size_t size_type;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -852,7 +852,7 @@ namespace etl
//********************************************************************* //*********************************************************************
void initialise_source_external_buffer_after_move() void initialise_source_external_buffer_after_move()
{ {
ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) ETL_SUBTRACT_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end)))
p_end = p_buffer; p_end = p_buffer;
} }
@ -862,7 +862,7 @@ namespace etl
//********************************************************************* //*********************************************************************
void initialise_destination_external_buffer_after_move() void initialise_destination_external_buffer_after_move()
{ {
ETL_ADD_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) ETL_ADD_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end)))
} }
}; };

View File

@ -67,10 +67,10 @@ namespace etl
typedef const value_type* const_pointer; typedef const value_type* const_pointer;
typedef value_type* iterator; typedef value_type* iterator;
typedef const value_type* const_iterator; typedef const value_type* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef size_t size_type; typedef size_t size_type;
typedef std::iterator_traits<iterator>::difference_type difference_type; typedef ETL_STD::iterator_traits<iterator>::difference_type difference_type;
public: public:
@ -211,7 +211,7 @@ namespace etl
// Size up if necessary. // Size up if necessary.
if (p_end < p_new_end) if (p_end < p_new_end)
{ {
std::fill(p_end, p_new_end, value); ETL_STD::fill(p_end, p_new_end, value);
} }
p_end = p_new_end; p_end = p_new_end;
@ -326,7 +326,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(static_cast<size_t>(d) <= CAPACITY, ETL_ERROR(vector_full)); ETL_ASSERT(static_cast<size_t>(d) <= CAPACITY, ETL_ERROR(vector_full));
#endif #endif
@ -402,7 +402,7 @@ namespace etl
if (position != end()) if (position != end())
{ {
++p_end; ++p_end;
std::copy_backward(position, end() - 1, end()); ETL_STD::copy_backward(position, end() - 1, end());
*position = value; *position = value;
} }
else else
@ -424,8 +424,8 @@ namespace etl
{ {
ETL_ASSERT((size() + 1) <= CAPACITY, ETL_ERROR(vector_full)); ETL_ASSERT((size() + 1) <= CAPACITY, ETL_ERROR(vector_full));
std::copy_backward(position, p_end, p_end + n); ETL_STD::copy_backward(position, p_end, p_end + n);
std::fill_n(position, n, value); ETL_STD::fill_n(position, n, value);
p_end += n; p_end += n;
} }
@ -441,12 +441,12 @@ namespace etl
template <typename TIterator> template <typename TIterator>
void insert(iterator position, TIterator first, TIterator last) void insert(iterator position, TIterator first, TIterator last)
{ {
size_t count = std::distance(first, last); size_t count = ETL_STD::distance(first, last);
ETL_ASSERT((size() + count) <= CAPACITY, ETL_ERROR(vector_full)); ETL_ASSERT((size() + count) <= CAPACITY, ETL_ERROR(vector_full));
std::copy_backward(position, p_end, p_end + count); ETL_STD::copy_backward(position, p_end, p_end + count);
std::copy(first, last, position); ETL_STD::copy(first, last, position);
p_end += count; p_end += count;
} }
@ -457,7 +457,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator erase(iterator i_element) iterator erase(iterator i_element)
{ {
std::copy(i_element + 1, end(), i_element); ETL_STD::copy(i_element + 1, end(), i_element);
--p_end; --p_end;
return i_element; return i_element;
@ -473,8 +473,8 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator erase(iterator first, iterator last) iterator erase(iterator first, iterator last)
{ {
std::copy(last, end(), first); ETL_STD::copy(last, end(), first);
size_t n_delete = std::distance(first, last); size_t n_delete = ETL_STD::distance(first, last);
// Just adjust the count. // Just adjust the count.
p_end -= n_delete; p_end -= n_delete;
@ -580,7 +580,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
inline bool operator ==(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs) inline bool operator ==(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -604,7 +604,7 @@ namespace etl
//*************************************************************************** //***************************************************************************
inline bool operator <(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs) inline bool operator <(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
} }
//*************************************************************************** //***************************************************************************

View File

@ -33,7 +33,7 @@ SOFTWARE.
///\ingroup private ///\ingroup private
#include <cmath> #include <math.h>
#include "../platform.h" #include "../platform.h"
#include "../absolute.h" #include "../absolute.h"
@ -57,7 +57,7 @@ namespace etl
template <typename TIString> template <typename TIString>
void add_alignment(TIString& str, typename TIString::iterator position, const etl::basic_format_spec<TIString>& format) void add_alignment(TIString& str, typename TIString::iterator position, const etl::basic_format_spec<TIString>& format)
{ {
uint32_t length = static_cast<uint32_t>(std::distance(position, str.end())); uint32_t length = static_cast<uint32_t>(ETL_STD::distance(position, str.end()));
if (length < format.get_width()) if (length < format.get_width())
{ {
@ -166,7 +166,7 @@ namespace etl
} }
// Reverse the string we appended. // Reverse the string we appended.
std::reverse(start, str.end()); ETL_STD::reverse(start, str.end());
} }
etl::private_to_string::add_alignment(str, start, format); etl::private_to_string::add_alignment(str, start, format);
@ -235,14 +235,14 @@ namespace etl
iterator start = str.end(); iterator start = str.end();
if (std::isnan(value) || std::isinf(value)) if (isnan(value) || isinf(value))
{ {
etl::private_to_string::add_nan_inf(std::isnan(value), std::isinf(value), str); etl::private_to_string::add_nan_inf(isnan(value), isinf(value), str);
} }
else else
{ {
// Make sure we format the two halves correctly. // Make sure we format the two halves correctly.
uint32_t max_precision = std::numeric_limits<T>::digits10; uint32_t max_precision = ETL_STD::numeric_limits<T>::digits10;
etl::basic_format_spec<TIString> integral_format = format; etl::basic_format_spec<TIString> integral_format = format;
integral_format.decimal().width(0).precision(format.get_precision() > max_precision ? max_precision : format.get_precision()); integral_format.decimal().width(0).precision(format.get_precision() > max_precision ? max_precision : format.get_precision());

View File

@ -37,7 +37,7 @@ SOFTWARE.
#define ETL_TARGET_DEVICE_ARM #define ETL_TARGET_DEVICE_ARM
#define ETL_TARGET_OS_NONE #define ETL_TARGET_OS_NONE
#define ETL_COMPILER_CLANG #define ETL_COMPILER_ARM6
#define ETL_CPP11_SUPPORTED 1 #define ETL_CPP11_SUPPORTED 1
#define ETL_CPP14_SUPPORTED 0 #define ETL_CPP14_SUPPORTED 0
#define ETL_CPP17_SUPPORTED 0 #define ETL_CPP17_SUPPORTED 0

View File

@ -330,7 +330,7 @@ namespace etl
#if defined(ETL_CHECK_PUSH_POP) #if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(queue_full)); ETL_ASSERT(!full(), ETL_ERROR(queue_full));
#endif #endif
::new (&p_buffer[in]) T(std::forward<Args>(args)...); ::new (&p_buffer[in]) T(ETL_STD::forward<Args>(args)...);
add_in(); add_in();
} }
#else #else

View File

@ -37,12 +37,17 @@ SOFTWARE.
#include <new> #include <new>
#include "platform.h" #include "platform.h"
#if ETL_HAS_MUTEX
#include "alignment.h" #include "alignment.h"
#include "parameter_type.h" #include "parameter_type.h"
#include "mutex.h" #include "mutex.h"
#include "memory_model.h" #include "memory_model.h"
#include "integral_limits.h" #include "integral_limits.h"
#include "stl/utility.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "48" #define ETL_FILE "48"
@ -174,7 +179,7 @@ namespace etl
{ {
access.lock(); access.lock();
bool result = emplace_implementation(std::forward<Args>(args)...); bool result = emplace_implementation(ETL_STD::forward<Args>(args)...);
access.unlock(); access.unlock();
@ -387,7 +392,7 @@ namespace etl
{ {
if (current_size != MAX_SIZE) if (current_size != MAX_SIZE)
{ {
::new (&p_buffer[write_index]) T(std::forward<Args>(args)...); ::new (&p_buffer[write_index]) T(ETL_STD::forward<Args>(args)...);
write_index = get_next_index(write_index, MAX_SIZE); write_index = get_next_index(write_index, MAX_SIZE);
@ -587,3 +592,4 @@ namespace etl
#undef ETL_FILE #undef ETL_FILE
#endif #endif
#endif

View File

@ -46,6 +46,8 @@ SOFTWARE.
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "47" #define ETL_FILE "47"
#if ETL_HAS_ATOMIC
namespace etl namespace etl
{ {
template <const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE> template <const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
@ -237,7 +239,7 @@ namespace etl
if (next_index != read.load(etl::memory_order_acquire)) if (next_index != read.load(etl::memory_order_acquire))
{ {
::new (&p_buffer[write_index]) T(std::forward<Args>(args)...); ::new (&p_buffer[write_index]) T(ETL_STD::forward<Args>(args)...);
write.store(next_index, etl::memory_order_release); write.store(next_index, etl::memory_order_release);
@ -471,6 +473,8 @@ namespace etl
}; };
} }
#endif
#undef ETL_FILE #undef ETL_FILE
#endif #endif

View File

@ -42,6 +42,8 @@ SOFTWARE.
#include "memory_model.h" #include "memory_model.h"
#include "integral_limits.h" #include "integral_limits.h"
#include "stl/utility.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "46" #define ETL_FILE "46"
@ -80,7 +82,7 @@ namespace etl
template <typename ... Args> template <typename ... Args>
bool emplace_from_isr(Args&&... args) bool emplace_from_isr(Args&&... args)
{ {
return emplace_implementation(std::forward<Args>(args)...); return emplace_implementation(ETL_STD::forward<Args>(args)...);
} }
#endif #endif
@ -205,7 +207,7 @@ namespace etl
{ {
if (current_size != MAX_SIZE) if (current_size != MAX_SIZE)
{ {
::new (&p_buffer[write_index]) T(std::forward<Args>(args)...); ::new (&p_buffer[write_index]) T(ETL_STD::forward<Args>(args)...);
write_index = get_next_index(write_index, MAX_SIZE); write_index = get_next_index(write_index, MAX_SIZE);
@ -438,7 +440,7 @@ namespace etl
{ {
TAccess::lock(); TAccess::lock();
bool result = this->emplace_implementation(std::forward<Args>(args)...); bool result = this->emplace_implementation(ETL_STD::forward<Args>(args)...);
TAccess::unlock(); TAccess::unlock();

View File

@ -43,6 +43,8 @@ SOFTWARE.
#include "integral_limits.h" #include "integral_limits.h"
#include "function.h" #include "function.h"
#include "stl/utility.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "46" #define ETL_FILE "46"
@ -81,7 +83,7 @@ namespace etl
template <typename ... Args> template <typename ... Args>
bool emplace_from_unlocked(Args&&... args) bool emplace_from_unlocked(Args&&... args)
{ {
return emplace_implementation(std::forward<Args>(args)...); return emplace_implementation(ETL_STD::forward<Args>(args)...);
} }
#endif #endif
@ -206,7 +208,7 @@ namespace etl
{ {
if (current_size != MAX_SIZE) if (current_size != MAX_SIZE)
{ {
::new (&p_buffer[write_index]) T(std::forward<Args>(args)...); ::new (&p_buffer[write_index]) T(ETL_STD::forward<Args>(args)...);
write_index = get_next_index(write_index, MAX_SIZE); write_index = get_next_index(write_index, MAX_SIZE);
@ -435,7 +437,7 @@ namespace etl
{ {
lock(); lock();
bool result = this->emplace_implementation(std::forward<Args>(args)...); bool result = this->emplace_implementation(ETL_STD::forward<Args>(args)...);
unlock(); unlock();

View File

@ -41,8 +41,8 @@ namespace etl
template <const size_t NUM, const size_t DEN = 1> template <const size_t NUM, const size_t DEN = 1>
struct ratio struct ratio
{ {
static const std::intmax_t num = NUM; static const intmax_t num = NUM;
static const std::intmax_t den = DEN; static const intmax_t den = DEN;
}; };
#if INT_MAX > INT32_MAX #if INT_MAX > INT32_MAX

View File

@ -41,6 +41,7 @@ SOFTWARE.
#include "parameter_type.h" #include "parameter_type.h"
#include "exception.h" #include "exception.h"
#include "static_assert.h" #include "static_assert.h"
#include "iterator.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "30" #define ETL_FILE "30"
@ -102,12 +103,12 @@ namespace etl
/// Can be used as a reference type for all reference_flat_maps containing a specific type. /// Can be used as a reference type for all reference_flat_maps containing a specific type.
///\ingroup reference_flat_map ///\ingroup reference_flat_map
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TMapped, typename TKeyCompare = std::less<TKey> > template <typename TKey, typename TMapped, typename TKeyCompare = ETL_STD::less<TKey> >
class ireference_flat_map class ireference_flat_map
{ {
public: public:
typedef std::pair<const TKey, TMapped> value_type; typedef ETL_PAIR<const TKey, TMapped> value_type;
protected: protected:
@ -125,7 +126,7 @@ namespace etl
typedef size_t size_type; typedef size_t size_type;
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -223,7 +224,7 @@ namespace etl
}; };
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -316,9 +317,9 @@ namespace etl
typename lookup_t::const_iterator ilookup; typename lookup_t::const_iterator ilookup;
}; };
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -524,10 +525,10 @@ namespace etl
template <typename TIterator> template <typename TIterator>
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
ETL_STATIC_ASSERT((etl::is_same<value_type, typename std::iterator_traits<TIterator>::value_type>::value), "Incompatible data for assign"); ETL_STATIC_ASSERT((etl::is_same<value_type, typename ETL_STD::iterator_traits<TIterator>::value_type>::value), "Incompatible data for assign");
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_map_full)); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_map_full));
#endif #endif
@ -544,7 +545,7 @@ namespace etl
/// If asserts or exceptions are enabled, emits flat_map_full if the reference_flat_map is already full. /// If asserts or exceptions are enabled, emits flat_map_full if the reference_flat_map is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(reference value) ETL_PAIR<iterator, bool> insert(reference value)
{ {
iterator i_element = lower_bound(value.first); iterator i_element = lower_bound(value.first);
@ -692,7 +693,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator lower_bound(key_parameter_t key) iterator lower_bound(key_parameter_t key)
{ {
return std::lower_bound(begin(), end(), key, compare); return ETL_STD::lower_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -702,7 +703,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator lower_bound(key_parameter_t key) const const_iterator lower_bound(key_parameter_t key) const
{ {
return std::lower_bound(cbegin(), cend(), key, compare); return ETL_STD::lower_bound(cbegin(), cend(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -712,7 +713,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator upper_bound(key_parameter_t key) iterator upper_bound(key_parameter_t key)
{ {
return std::upper_bound(begin(), end(), key, compare); return ETL_STD::upper_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -722,7 +723,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator upper_bound(key_parameter_t key) const const_iterator upper_bound(key_parameter_t key) const
{ {
return std::upper_bound(begin(), end(), key, compare); return ETL_STD::upper_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -730,11 +731,11 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
iterator i_lower = std::lower_bound(begin(), end(), key, compare); iterator i_lower = ETL_STD::lower_bound(begin(), end(), key, compare);
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare)); return ETL_MAKE_PAIR(i_lower, ETL_STD::upper_bound(i_lower, end(), key, compare));
} }
//********************************************************************* //*********************************************************************
@ -742,11 +743,11 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare); const_iterator i_lower = ETL_STD::lower_bound(cbegin(), cend(), key, compare);
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare)); return ETL_MAKE_PAIR(i_lower, ETL_STD::upper_bound(i_lower, cend(), key, compare));
} }
//************************************************************************* //*************************************************************************
@ -818,9 +819,9 @@ namespace etl
///\param i_element The place to insert. ///\param i_element The place to insert.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert_at(iterator i_element, value_type& value) ETL_PAIR<iterator, bool> insert_at(iterator i_element, value_type& value)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
if (i_element == end()) if (i_element == end())
{ {
@ -885,7 +886,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::ireference_flat_map<TKey, TMapped, TKeyCompare>& lhs, const etl::ireference_flat_map<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::ireference_flat_map<TKey, TMapped, TKeyCompare>& lhs, const etl::ireference_flat_map<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -905,11 +906,11 @@ namespace etl
/// A reference_flat_map implementation that uses a fixed size buffer. /// A reference_flat_map implementation that uses a fixed size buffer.
///\tparam TKey The key type. ///\tparam TKey The key type.
///\tparam TValue The value type. ///\tparam TValue The value type.
///\tparam TCompare The type to compare keys. Default = std::less<TKey> ///\tparam TCompare The type to compare keys. Default = ETL_STD::less<TKey>
///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\tparam MAX_SIZE_ The maximum number of elements that can be stored.
///\ingroup reference_flat_map ///\ingroup reference_flat_map
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = std::less<TKey> > template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<TKey> >
class reference_flat_map : public ireference_flat_map<TKey, TValue, TCompare> class reference_flat_map : public ireference_flat_map<TKey, TValue, TCompare>
{ {
public: public:

View File

@ -38,6 +38,7 @@ SOFTWARE.
#include "error_handler.h" #include "error_handler.h"
#include "debug_count.h" #include "debug_count.h"
#include "vector.h" #include "vector.h"
#include "iterator.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "31" #define ETL_FILE "31"
@ -77,12 +78,12 @@ namespace etl
/// Can be used as a reference type for all reference_flat_multimaps containing a specific type. /// Can be used as a reference type for all reference_flat_multimaps containing a specific type.
///\ingroup reference_flat_multimap ///\ingroup reference_flat_multimap
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TMapped, typename TKeyCompare = std::less<TKey> > template <typename TKey, typename TMapped, typename TKeyCompare = ETL_STD::less<TKey> >
class ireference_flat_multimap class ireference_flat_multimap
{ {
public: public:
typedef std::pair<const TKey, TMapped> value_type; typedef ETL_PAIR<const TKey, TMapped> value_type;
protected: protected:
@ -100,7 +101,7 @@ namespace etl
typedef size_t size_type; typedef size_t size_type;
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -198,7 +199,7 @@ namespace etl
}; };
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -291,9 +292,9 @@ namespace etl
typename lookup_t::const_iterator ilookup; typename lookup_t::const_iterator ilookup;
}; };
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -442,7 +443,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multimap_full));
#endif #endif
@ -459,11 +460,11 @@ namespace etl
/// If asserts or exceptions are enabled, emits reference_flat_multimap_full if the reference_flat_multimap is already full. /// If asserts or exceptions are enabled, emits reference_flat_multimap_full if the reference_flat_multimap is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(value_type& value) ETL_PAIR<iterator, bool> insert(value_type& value)
{ {
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multimap_full)); ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multimap_full));
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
iterator i_element = lower_bound(value.first); iterator i_element = lower_bound(value.first);
@ -504,7 +505,7 @@ namespace etl
//********************************************************************* //*********************************************************************
size_t erase(key_parameter_t key) size_t erase(key_parameter_t key)
{ {
std::pair<iterator, iterator> range = equal_range(key); ETL_PAIR<iterator, iterator> range = equal_range(key);
if (range.first == end()) if (range.first == end())
{ {
@ -512,7 +513,7 @@ namespace etl
} }
else else
{ {
size_t d = std::distance(range.first, range.second); size_t d = ETL_STD::distance(range.first, range.second);
erase(range.first, range.second); erase(range.first, range.second);
return d; return d;
} }
@ -602,9 +603,9 @@ namespace etl
//********************************************************************* //*********************************************************************
size_t count(key_parameter_t key) const size_t count(key_parameter_t key) const
{ {
std::pair<const_iterator, const_iterator> range = equal_range(key); ETL_PAIR<const_iterator, const_iterator> range = equal_range(key);
return std::distance(range.first, range.second); return ETL_STD::distance(range.first, range.second);
} }
//********************************************************************* //*********************************************************************
@ -614,7 +615,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator lower_bound(key_parameter_t key) iterator lower_bound(key_parameter_t key)
{ {
return std::lower_bound(begin(), end(), key, compare); return ETL_STD::lower_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -624,7 +625,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator lower_bound(key_parameter_t key) const const_iterator lower_bound(key_parameter_t key) const
{ {
return std::lower_bound(cbegin(), cend(), key, compare); return ETL_STD::lower_bound(cbegin(), cend(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -634,7 +635,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator upper_bound(key_parameter_t key) iterator upper_bound(key_parameter_t key)
{ {
return std::upper_bound(begin(), end(), key, compare); return ETL_STD::upper_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -644,7 +645,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator upper_bound(key_parameter_t key) const const_iterator upper_bound(key_parameter_t key) const
{ {
return std::upper_bound(begin(), end(), key, compare); return ETL_STD::upper_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -652,11 +653,11 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
iterator i_lower = std::lower_bound(begin(), end(), key, compare); iterator i_lower = ETL_STD::lower_bound(begin(), end(), key, compare);
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare)); return ETL_MAKE_PAIR(i_lower, ETL_STD::upper_bound(i_lower, end(), key, compare));
} }
//********************************************************************* //*********************************************************************
@ -664,11 +665,11 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare); const_iterator i_lower = ETL_STD::lower_bound(cbegin(), cend(), key, compare);
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare)); return ETL_MAKE_PAIR(i_lower, ETL_STD::upper_bound(i_lower, cend(), key, compare));
} }
//************************************************************************* //*************************************************************************
@ -740,9 +741,9 @@ namespace etl
///\param i_element The place to insert. ///\param i_element The place to insert.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert_at(iterator i_element, value_type& value) ETL_PAIR<iterator, bool> insert_at(iterator i_element, value_type& value)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
if (i_element == end()) if (i_element == end())
{ {
@ -798,7 +799,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::ireference_flat_multimap<TKey, TMapped, TKeyCompare>& lhs, const etl::ireference_flat_multimap<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::ireference_flat_multimap<TKey, TMapped, TKeyCompare>& lhs, const etl::ireference_flat_multimap<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -814,15 +815,15 @@ namespace etl
return !(lhs == rhs); return !(lhs == rhs);
} }
template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = std::less<TKey> >
//*************************************************************************** //***************************************************************************
/// A reference_flat_multimap implementation that uses a fixed size buffer. /// A reference_flat_multimap implementation that uses a fixed size buffer.
///\tparam TKey The key type. ///\tparam TKey The key type.
///\tparam TValue The value type. ///\tparam TValue The value type.
///\tparam TCompare The type to compare keys. Default = std::less<TKey> ///\tparam TCompare The type to compare keys. Default = ETL_STD::less<TKey>
///\tparam MAX_SIZE_ The maximum number of elements that can be stored. ///\tparam MAX_SIZE_ The maximum number of elements that can be stored.
///\ingroup reference_flat_multimap ///\ingroup reference_flat_multimap
//*************************************************************************** //***************************************************************************
template <typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<TKey> >
class reference_flat_multimap : public ireference_flat_multimap<TKey, TValue, TCompare> class reference_flat_multimap : public ireference_flat_multimap<TKey, TValue, TCompare>
{ {
public: public:

View File

@ -98,7 +98,7 @@ namespace etl
/// Can be used as a reference type for all reference_flat_multisets containing a specific type. /// Can be used as a reference type for all reference_flat_multisets containing a specific type.
///\ingroup reference_flat_multiset ///\ingroup reference_flat_multiset
//*************************************************************************** //***************************************************************************
template <typename T, typename TKeyCompare = std::less<T> > template <typename T, typename TKeyCompare = ETL_STD::less<T> >
class ireference_flat_multiset class ireference_flat_multiset
{ {
public: public:
@ -119,7 +119,7 @@ namespace etl
public: public:
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -217,7 +217,7 @@ namespace etl
}; };
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -316,9 +316,9 @@ namespace etl
public: public:
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//********************************************************************* //*********************************************************************
/// Returns an iterator to the beginning of the reference_flat_multiset. /// Returns an iterator to the beginning of the reference_flat_multiset.
@ -439,7 +439,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_multiset_full));
#endif #endif
@ -456,13 +456,13 @@ namespace etl
/// If asserts or exceptions are enabled, emits reference_flat_multiset_full if the reference_flat_multiset is already full. /// If asserts or exceptions are enabled, emits reference_flat_multiset_full if the reference_flat_multiset is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(value_type& value) ETL_PAIR<iterator, bool> insert(value_type& value)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full)); ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full));
iterator i_element = std::lower_bound(begin(), end(), value, compare); iterator i_element = ETL_STD::lower_bound(begin(), end(), value, compare);
if (i_element == end()) if (i_element == end())
{ {
@ -516,7 +516,7 @@ namespace etl
//********************************************************************* //*********************************************************************
size_t erase(parameter_t key) size_t erase(parameter_t key)
{ {
std::pair<iterator, iterator> range = equal_range(key); ETL_PAIR<iterator, iterator> range = equal_range(key);
if (range.first == end()) if (range.first == end())
{ {
@ -524,7 +524,7 @@ namespace etl
} }
else else
{ {
size_t d = std::distance(range.first, range.second); size_t d = ETL_STD::distance(range.first, range.second);
erase(range.first, range.second); erase(range.first, range.second);
return d; return d;
} }
@ -566,7 +566,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator find(parameter_t key) iterator find(parameter_t key)
{ {
iterator itr = std::lower_bound(begin(), end(), key, compare); iterator itr = ETL_STD::lower_bound(begin(), end(), key, compare);
if (itr != end()) if (itr != end())
{ {
@ -590,7 +590,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator find(parameter_t key) const const_iterator find(parameter_t key) const
{ {
const_iterator itr = std::lower_bound(begin(), end(), key, compare); const_iterator itr = ETL_STD::lower_bound(begin(), end(), key, compare);
if (itr != end()) if (itr != end())
{ {
@ -614,9 +614,9 @@ namespace etl
//********************************************************************* //*********************************************************************
size_t count(parameter_t key) const size_t count(parameter_t key) const
{ {
std::pair<const_iterator, const_iterator> range = equal_range(key); ETL_PAIR<const_iterator, const_iterator> range = equal_range(key);
return std::distance(range.first, range.second); return ETL_STD::distance(range.first, range.second);
} }
//********************************************************************* //*********************************************************************
@ -626,7 +626,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator lower_bound(parameter_t key) iterator lower_bound(parameter_t key)
{ {
return std::lower_bound(begin(), end(), key, compare); return ETL_STD::lower_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -636,7 +636,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator lower_bound(parameter_t key) const const_iterator lower_bound(parameter_t key) const
{ {
return std::lower_bound(cbegin(), cend(), key, compare); return ETL_STD::lower_bound(cbegin(), cend(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -646,7 +646,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator upper_bound(parameter_t key) iterator upper_bound(parameter_t key)
{ {
return std::upper_bound(begin(), end(), key, compare); return ETL_STD::upper_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -656,7 +656,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator upper_bound(parameter_t key) const const_iterator upper_bound(parameter_t key) const
{ {
return std::upper_bound(cbegin(), cend(), key, compare); return ETL_STD::upper_bound(cbegin(), cend(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -664,9 +664,9 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(parameter_t key) ETL_PAIR<iterator, iterator> equal_range(parameter_t key)
{ {
return std::equal_range(begin(), end(), key, compare); return ETL_STD::equal_range(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -674,9 +674,9 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(parameter_t key) const
{ {
return std::equal_range(begin(), end(), key, compare); return ETL_STD::equal_range(begin(), end(), key, compare);
} }
//************************************************************************* //*************************************************************************
@ -748,9 +748,9 @@ namespace etl
///\param i_element The place to insert. ///\param i_element The place to insert.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert_at(iterator i_element, reference value) ETL_PAIR<iterator, bool> insert_at(iterator i_element, reference value)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
if (i_element == end()) if (i_element == end())
{ {
@ -805,7 +805,7 @@ namespace etl
/// An reference flat set /// An reference flat set
///\ingroup reference_flat_multiset ///\ingroup reference_flat_multiset
//*************************************************************************** //***************************************************************************
template <typename TKey, const size_t MAX_SIZE_, typename TKeyCompare = std::less<TKey> > template <typename TKey, const size_t MAX_SIZE_, typename TKeyCompare = ETL_STD::less<TKey> >
class reference_flat_multiset : public ireference_flat_multiset<TKey, TKeyCompare> class reference_flat_multiset : public ireference_flat_multiset<TKey, TKeyCompare>
{ {
public: public:
@ -868,7 +868,7 @@ namespace etl
template <typename T, typename TKeyCompare> template <typename T, typename TKeyCompare>
bool operator ==(const etl::ireference_flat_multiset<T, TKeyCompare>& lhs, const etl::ireference_flat_multiset<T, TKeyCompare>& rhs) bool operator ==(const etl::ireference_flat_multiset<T, TKeyCompare>& lhs, const etl::ireference_flat_multiset<T, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************

View File

@ -45,6 +45,7 @@ SOFTWARE.
#include "error_handler.h" #include "error_handler.h"
#include "exception.h" #include "exception.h"
#include "vector.h" #include "vector.h"
#include "iterator.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "32" #define ETL_FILE "32"
@ -98,7 +99,7 @@ namespace etl
/// Can be used as a reference type for all reference_flat_sets containing a specific type. /// Can be used as a reference type for all reference_flat_sets containing a specific type.
///\ingroup reference_flat_set ///\ingroup reference_flat_set
//*************************************************************************** //***************************************************************************
template <typename T, typename TKeyCompare = std::less<T> > template <typename T, typename TKeyCompare = ETL_STD::less<T> >
class ireference_flat_set class ireference_flat_set
{ {
public: public:
@ -119,7 +120,7 @@ namespace etl
public: public:
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -217,7 +218,7 @@ namespace etl
}; };
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -316,9 +317,9 @@ namespace etl
public: public:
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//********************************************************************* //*********************************************************************
/// Returns an iterator to the beginning of the reference_flat_set. /// Returns an iterator to the beginning of the reference_flat_set.
@ -439,7 +440,7 @@ namespace etl
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_set_full)); ETL_ASSERT(d <= difference_type(capacity()), ETL_ERROR(flat_set_full));
#endif #endif
@ -456,7 +457,7 @@ namespace etl
/// If asserts or exceptions are enabled, emits reference_flat_set_full if the reference_flat_set is already full. /// If asserts or exceptions are enabled, emits reference_flat_set_full if the reference_flat_set is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(reference value) ETL_PAIR<iterator, bool> insert(reference value)
{ {
iterator i_element = lower_bound(value); iterator i_element = lower_bound(value);
@ -546,7 +547,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator find(parameter_t key) iterator find(parameter_t key)
{ {
iterator itr = std::lower_bound(begin(), end(), key, compare); iterator itr = ETL_STD::lower_bound(begin(), end(), key, compare);
if (itr != end()) if (itr != end())
{ {
@ -570,7 +571,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator find(parameter_t key) const const_iterator find(parameter_t key) const
{ {
const_iterator itr = std::lower_bound(begin(), end(), key, compare); const_iterator itr = ETL_STD::lower_bound(begin(), end(), key, compare);
if (itr != end()) if (itr != end())
{ {
@ -604,7 +605,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator lower_bound(parameter_t key) iterator lower_bound(parameter_t key)
{ {
return std::lower_bound(begin(), end(), key, compare); return ETL_STD::lower_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -614,7 +615,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator lower_bound(parameter_t key) const const_iterator lower_bound(parameter_t key) const
{ {
return std::lower_bound(cbegin(), cend(), key, compare); return ETL_STD::lower_bound(cbegin(), cend(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -624,7 +625,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator upper_bound(parameter_t key) iterator upper_bound(parameter_t key)
{ {
return std::upper_bound(begin(), end(), key, compare); return ETL_STD::upper_bound(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -634,7 +635,7 @@ namespace etl
//********************************************************************* //*********************************************************************
const_iterator upper_bound(parameter_t key) const const_iterator upper_bound(parameter_t key) const
{ {
return std::upper_bound(cbegin(), cend(), key, compare); return ETL_STD::upper_bound(cbegin(), cend(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -642,9 +643,9 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(parameter_t key) ETL_PAIR<iterator, iterator> equal_range(parameter_t key)
{ {
return std::equal_range(begin(), end(), key, compare); return ETL_STD::equal_range(begin(), end(), key, compare);
} }
//********************************************************************* //*********************************************************************
@ -652,9 +653,9 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair. ///\return An iterator pair.
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(parameter_t key) const
{ {
return std::upper_bound(cbegin(), cend(), key, compare); return ETL_STD::upper_bound(cbegin(), cend(), key, compare);
} }
//************************************************************************* //*************************************************************************
@ -726,9 +727,9 @@ namespace etl
///\param i_element The place to insert. ///\param i_element The place to insert.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert_at(iterator i_element, reference value) ETL_PAIR<iterator, bool> insert_at(iterator i_element, reference value)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
if (i_element == end()) if (i_element == end())
{ {
@ -787,7 +788,7 @@ namespace etl
/// An reference flat set /// An reference flat set
///\ingroup reference_flat_set ///\ingroup reference_flat_set
//*************************************************************************** //***************************************************************************
template <typename TKey, const size_t MAX_SIZE_, typename TKeyCompare = std::less<TKey> > template <typename TKey, const size_t MAX_SIZE_, typename TKeyCompare = ETL_STD::less<TKey> >
class reference_flat_set : public ireference_flat_set<TKey, TKeyCompare> class reference_flat_set : public ireference_flat_set<TKey, TKeyCompare>
{ {
public: public:
@ -850,7 +851,7 @@ namespace etl
template <typename T, typename TKeyCompare> template <typename T, typename TKeyCompare>
bool operator ==(const etl::ireference_flat_set<T, TKeyCompare>& lhs, const etl::ireference_flat_set<T, TKeyCompare>& rhs) bool operator ==(const etl::ireference_flat_set<T, TKeyCompare>& lhs, const etl::ireference_flat_set<T, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************

View File

@ -285,7 +285,7 @@ namespace etl
if (!task_list.full()) if (!task_list.full())
{ {
typename task_list_t::iterator itask = std::upper_bound(task_list.begin(), typename task_list_t::iterator itask = ETL_STD::upper_bound(task_list.begin(),
task_list.end(), task_list.end(),
task.get_task_priority(), task.get_task_priority(),
compare_priority()); compare_priority());

View File

@ -44,6 +44,7 @@ SOFTWARE.
#include "nullptr.h" #include "nullptr.h"
#include "type_traits.h" #include "type_traits.h"
#include "parameter_type.h" #include "parameter_type.h"
#include "iterator.h"
#include "stl/algorithm.h" #include "stl/algorithm.h"
#include "stl/iterator.h" #include "stl/iterator.h"
@ -456,7 +457,7 @@ namespace etl
/// A templated base for all etl::set types. /// A templated base for all etl::set types.
///\ingroup set ///\ingroup set
//*************************************************************************** //***************************************************************************
template <typename T, typename TCompare = std::less<T> > template <typename T, typename TCompare = ETL_STD::less<T> >
class iset : public etl::set_base class iset : public etl::set_base
{ {
public: public:
@ -548,7 +549,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// iterator. /// iterator.
//************************************************************************* //*************************************************************************
class iterator : public std::iterator<std::bidirectional_iterator_tag, value_type> class iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, value_type>
{ {
public: public:
@ -653,7 +654,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// const_iterator /// const_iterator
//************************************************************************* //*************************************************************************
class const_iterator : public std::iterator<std::bidirectional_iterator_tag, const value_type> class const_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, const value_type>
{ {
public: public:
@ -760,10 +761,10 @@ namespace etl
}; };
friend class const_iterator; friend class const_iterator;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//************************************************************************* //*************************************************************************
/// Assignment operator. /// Assignment operator.
@ -910,9 +911,9 @@ namespace etl
/// Returns two iterators with bounding (lower bound, upper bound) the /// Returns two iterators with bounding (lower bound, upper bound) the
/// value provided /// value provided
//************************************************************************* //*************************************************************************
std::pair<iterator, iterator> equal_range(const value_type& value) ETL_PAIR<iterator, iterator> equal_range(const value_type& value)
{ {
return std::make_pair<iterator, iterator>( return ETL_MAKE_PAIR<iterator, iterator>(
iterator(*this, find_lower_node(root_node, value)), iterator(*this, find_lower_node(root_node, value)),
iterator(*this, find_upper_node(root_node, value))); iterator(*this, find_upper_node(root_node, value)));
} }
@ -921,9 +922,9 @@ namespace etl
/// Returns two const iterators with bounding (lower bound, upper bound) /// Returns two const iterators with bounding (lower bound, upper bound)
/// the value provided. /// the value provided.
//************************************************************************* //*************************************************************************
std::pair<const_iterator, const_iterator> equal_range(const value_type& value) const ETL_PAIR<const_iterator, const_iterator> equal_range(const value_type& value) const
{ {
return std::make_pair<const_iterator, const_iterator>( return ETL_MAKE_PAIR<const_iterator, const_iterator>(
const_iterator(*this, find_lower_node(root_node, value)), const_iterator(*this, find_lower_node(root_node, value)),
const_iterator(*this, find_upper_node(root_node, value))); const_iterator(*this, find_upper_node(root_node, value)));
} }
@ -1014,7 +1015,7 @@ namespace etl
/// If asserts or exceptions are enabled, emits set_full if the set is already full. /// If asserts or exceptions are enabled, emits set_full if the set is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(value_type& value) ETL_PAIR<iterator, bool> insert(value_type& value)
{ {
// Default to no inserted node // Default to no inserted node
Node* inserted_node = nullptr; Node* inserted_node = nullptr;
@ -1030,7 +1031,7 @@ namespace etl
inserted = inserted_node == &node; inserted = inserted_node == &node;
// Insert node into tree and return iterator to new node location in tree // Insert node into tree and return iterator to new node location in tree
return std::make_pair(iterator(*this, inserted_node), inserted); return ETL_MAKE_PAIR(iterator(*this, inserted_node), inserted);
} }
//********************************************************************* //*********************************************************************
@ -1949,7 +1950,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// A templated set implementation that uses a fixed size buffer. /// A templated set implementation that uses a fixed size buffer.
//************************************************************************* //*************************************************************************
template <typename T, const size_t MAX_SIZE_, typename TCompare = std::less<T> > template <typename T, const size_t MAX_SIZE_, typename TCompare = ETL_STD::less<T> >
class set : public etl::iset<T, TCompare> class set : public etl::iset<T, TCompare>
{ {
public: public:
@ -2036,7 +2037,7 @@ namespace etl
template <typename T, typename TCompare> template <typename T, typename TCompare>
bool operator ==(const etl::iset<T, TCompare>& lhs, const etl::iset<T, TCompare>& rhs) bool operator ==(const etl::iset<T, TCompare>& lhs, const etl::iset<T, TCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -2062,7 +2063,7 @@ namespace etl
template <typename T, typename TCompare> template <typename T, typename TCompare>
bool operator <(const etl::iset<T, TCompare>& lhs, const etl::iset<T, TCompare>& rhs) bool operator <(const etl::iset<T, TCompare>& lhs, const etl::iset<T, TCompare>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), return ETL_STD::lexicographical_compare(lhs.begin(),
lhs.end(), lhs.end(),
rhs.begin(), rhs.begin(),
rhs.end()); rhs.end());

View File

@ -278,7 +278,7 @@ namespace etl
ETL_ASSERT(!full(), ETL_ERROR(stack_full)); ETL_ASSERT(!full(), ETL_ERROR(stack_full));
#endif #endif
base_t::add_in(); base_t::add_in();
::new (&p_buffer[top_index]) T(std::forward<Args>(args)...); ::new (&p_buffer[top_index]) T(ETL_STD::forward<Args>(args)...);
} }
#else #else
//************************************************************************* //*************************************************************************
@ -408,7 +408,7 @@ namespace etl
//************************************************************************* //*************************************************************************
void reverse() void reverse()
{ {
std::reverse(p_buffer, p_buffer + current_size); ETL_STD::reverse(p_buffer, p_buffer + current_size);
} }
//************************************************************************* //*************************************************************************

View File

@ -235,7 +235,7 @@ namespace etl
} }
else else
{ {
return std::find_if(state_table.begin(), return ETL_STD::find_if(state_table.begin(),
state_table.end(), state_table.end(),
is_state(state_id)); is_state(state_id));
} }
@ -280,7 +280,7 @@ namespace etl
while (t != transition_table.end()) while (t != transition_table.end())
{ {
// Scan the transition table from the latest position. // Scan the transition table from the latest position.
t = std::find_if(t, t = ETL_STD::find_if(t,
transition_table.end(), transition_table.end(),
is_transition(event_id, current_state_id)); is_transition(event_id, current_state_id));

View File

@ -33,6 +33,10 @@ SOFTWARE.
#include "../platform.h" #include "../platform.h"
#include "../private/choose_namespace.h"
#include "../private/choose_tag_types.h"
#include "../private/choose_pair_types.h"
#if defined(ETL_NO_STL) #if defined(ETL_NO_STL)
#include "alternate/algorithm.h" #include "alternate/algorithm.h"
#else #else

View File

@ -32,22 +32,59 @@ SOFTWARE.
#define ETL_STL_ALTERNATE_ALGORITHM_INCLUDED #define ETL_STL_ALTERNATE_ALGORITHM_INCLUDED
#include "../../platform.h" #include "../../platform.h"
#include "../../type_traits.h"
#include <string.h> #include <string.h>
#include "../../type_traits.h" #include "etl/private/choose_tag_types.h"
#include "etl/private/choose_pair_types.h"
#include "choose_namespace.h" // Local alternate definitions.
#include "iterator.h" #include "iterator.h"
#include "functional.h" #include "functional.h"
#include "utility.h" #include "utility.h"
namespace ETLSTD namespace etlstd
{ {
//***************************************************************************
// swap
template <typename T>
void swap(T& a, T& b)
{
T c = a;
a = b;
b = c;
}
//***************************************************************************
// iter_swap
template <typename TIterator1, typename TIterator2>
void iter_swap(TIterator1 a, TIterator2 b)
{
typename etlstd::iterator_traits<TIterator1>::value_type c = *a;
*a = *b;
*b = c;
}
//***************************************************************************
// swap_ranges
template <typename T1terator1, typename TIterator2>
TIterator2 swap_ranges(T1terator1 first1,
T1terator1 last1,
TIterator2 first2)
{
while (first1 != last1)
{
iter_swap(first1++, first2++);
}
return first2;
}
//*************************************************************************** //***************************************************************************
// advance // advance
template <typename TIterator, typename TDistance> template <typename TIterator, typename TDistance>
typename etl::enable_if<!etl::is_same<typename ETLSTD::iterator_traits<TIterator>::iterator_tag, ETLSTD::random_access_iterator_tag>::value, void>::type typename etl::enable_if<!etl::is_same<typename etlstd::iterator_traits<TIterator>::iterator_tag, etlstd::random_access_iterator_tag>::value, void>::type
advance(TIterator itr, TDistance distance) advance(TIterator itr, TDistance distance)
{ {
while (distance-- != 0) while (distance-- != 0)
@ -57,7 +94,7 @@ namespace ETLSTD
} }
template <typename TIterator, typename TDistance> template <typename TIterator, typename TDistance>
typename etl::enable_if<etl::is_same<typename ETLSTD::iterator_traits<TIterator>::iterator_tag, ETLSTD::random_access_iterator_tag>::value, void>::type typename etl::enable_if<etl::is_same<typename etlstd::iterator_traits<TIterator>::iterator_tag, etlstd::random_access_iterator_tag>::value, void>::type
advance(TIterator itr, TDistance distance) advance(TIterator itr, TDistance distance)
{ {
return itr += distance; return itr += distance;
@ -69,11 +106,11 @@ namespace ETLSTD
template <typename TIterator1, typename TIterator2> template <typename TIterator1, typename TIterator2>
typename etl::enable_if<etl::is_pointer<TIterator1>::value && typename etl::enable_if<etl::is_pointer<TIterator1>::value &&
etl::is_pointer<TIterator2>::value && etl::is_pointer<TIterator2>::value &&
etl::is_pod<typename ETLSTD::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type etl::is_pod<typename etlstd::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
copy(TIterator1 sb, TIterator1 se, TIterator2 db) copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{ {
typedef typename ETLSTD::iterator_traits<TIterator1>::value_type value_t; typedef typename etlstd::iterator_traits<TIterator1>::value_type value_t;
typedef typename ETLSTD::iterator_traits<TIterator1>::difference_type difference_t; typedef typename etlstd::iterator_traits<TIterator1>::difference_type difference_t;
difference_t count = (se - sb); difference_t count = (se - sb);
@ -84,7 +121,7 @@ namespace ETLSTD
template <typename TIterator1, typename TIterator2> template <typename TIterator1, typename TIterator2>
typename etl::enable_if<!etl::is_pointer<TIterator1>::value || typename etl::enable_if<!etl::is_pointer<TIterator1>::value ||
!etl::is_pointer<TIterator2>::value || !etl::is_pointer<TIterator2>::value ||
!etl::is_pod<typename ETLSTD::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type !etl::is_pod<typename etlstd::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
copy(TIterator1 sb, TIterator1 se, TIterator2 db) copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{ {
while (sb != se) while (sb != se)
@ -95,16 +132,29 @@ namespace ETLSTD
return db; return db;
} }
//***************************************************************************
// reverse_copy
template <typename TIterator1, typename TIterator2>
TIterator2 reverse_copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{
while (sb != se)
{
*(db++) = *(--se);
}
return db;
}
//*************************************************************************** //***************************************************************************
// copy_n // copy_n
// Pointer // Pointer
template <typename TIterator1, typename TSize, typename TIterator2> template <typename TIterator1, typename TSize, typename TIterator2>
typename etl::enable_if<etl::is_pointer<TIterator1>::value && typename etl::enable_if<etl::is_pointer<TIterator1>::value &&
etl::is_pointer<TIterator2>::value && etl::is_pointer<TIterator2>::value &&
etl::is_pod<typename ETLSTD::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type etl::is_pod<typename etlstd::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
copy_n(TIterator1 sb, TSize count, TIterator2 db) copy_n(TIterator1 sb, TSize count, TIterator2 db)
{ {
typedef typename ETLSTD::iterator_traits<TIterator1>::value_type value_t; typedef typename etlstd::iterator_traits<TIterator1>::value_type value_t;
return TIterator2(memcpy(db, sb, sizeof(value_t) * count)) + count; return TIterator2(memcpy(db, sb, sizeof(value_t) * count)) + count;
} }
@ -113,7 +163,7 @@ namespace ETLSTD
template <typename TIterator1, typename TSize, typename TIterator2> template <typename TIterator1, typename TSize, typename TIterator2>
typename etl::enable_if<!etl::is_pointer<TIterator1>::value || typename etl::enable_if<!etl::is_pointer<TIterator1>::value ||
!etl::is_pointer<TIterator2>::value || !etl::is_pointer<TIterator2>::value ||
!etl::is_pod<typename ETLSTD::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type !etl::is_pod<typename etlstd::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
copy_n(TIterator1 sb, TSize count, TIterator2 db) copy_n(TIterator1 sb, TSize count, TIterator2 db)
{ {
while (count != 0) while (count != 0)
@ -131,10 +181,10 @@ namespace ETLSTD
template <typename TIterator1, typename TIterator2> template <typename TIterator1, typename TIterator2>
typename etl::enable_if<etl::is_pointer<TIterator1>::value && typename etl::enable_if<etl::is_pointer<TIterator1>::value &&
etl::is_pointer<TIterator2>::value && etl::is_pointer<TIterator2>::value &&
etl::is_pod<typename ETLSTD::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type etl::is_pod<typename etlstd::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de) copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{ {
typedef typename ETLSTD::iterator_traits<TIterator1>::value_type value_t; typedef typename etlstd::iterator_traits<TIterator1>::value_type value_t;
const size_t length = (se - sb); const size_t length = (se - sb);
@ -145,7 +195,7 @@ namespace ETLSTD
template <typename TIterator1, typename TIterator2> template <typename TIterator1, typename TIterator2>
typename etl::enable_if<!etl::is_pointer<TIterator1>::value || typename etl::enable_if<!etl::is_pointer<TIterator1>::value ||
!etl::is_pointer<TIterator2>::value || !etl::is_pointer<TIterator2>::value ||
!etl::is_pod<typename ETLSTD::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type !etl::is_pod<typename etlstd::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de) copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{ {
while (se != sb) while (se != sb)
@ -163,7 +213,7 @@ namespace ETLSTD
{ {
while (sb != se) while (sb != se)
{ {
*db++ = ETLSTD::move(*sb++); *db++ = etlstd::move(*sb++);
} }
return db; return db;
@ -176,27 +226,55 @@ namespace ETLSTD
{ {
while (sb != se) while (sb != se)
{ {
*(--de) = ETLSTD::move(*(--se)); *(--de) = etlstd::move(*(--se));
} }
return de; return de;
} }
//***************************************************************************
// reverse
// Pointers
template <typename TIterator>
typename etl::enable_if<etl::is_pointer<TIterator>::value, void>::type
reverse(TIterator b, TIterator e)
{
if (b != e)
{
while (b < --e)
{
etlstd::iter_swap(b, e);
++b;
}
}
}
// Other
template <typename TIterator>
typename etl::enable_if<!etl::is_pointer<TIterator>::value, void>::type
reverse(TIterator b, TIterator e)
{
while ((b != e) && (b != --e))
{
etlstd::iter_swap(b++, e);
}
}
//*************************************************************************** //***************************************************************************
// lower_bound // lower_bound
template<typename TIterator, typename TValue, typename TCompare> template<typename TIterator, typename TValue, typename TCompare>
TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare) TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
{ {
typedef typename ETLSTD::iterator_traits<TIterator>::difference_type difference_t; typedef typename etlstd::iterator_traits<TIterator>::difference_type difference_t;
difference_t count = ETLSTD::distance(first, last); difference_t count = etlstd::distance(first, last);
while (count > 0) while (count > 0)
{ {
TIterator itr = first; TIterator itr = first;
difference_t step = count / 2; difference_t step = count / 2;
ETLSTD::advance(itr, step); etlstd::advance(itr, step);
if (compare(*itr, value)) if (compare(*itr, value))
{ {
@ -215,9 +293,9 @@ namespace ETLSTD
template<typename TIterator, typename TValue> template<typename TIterator, typename TValue>
TIterator lower_bound(TIterator first, TIterator last, const TValue& value) TIterator lower_bound(TIterator first, TIterator last, const TValue& value)
{ {
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator>::value_type> compare; typedef etlstd::less<typename etlstd::iterator_traits<TIterator>::value_type> compare;
return ETLSTD::lower_bound(first, last, value, compare()); return etlstd::lower_bound(first, last, value, compare());
} }
//*************************************************************************** //***************************************************************************
@ -225,16 +303,16 @@ namespace ETLSTD
template<typename TIterator, typename TValue, typename TCompare> template<typename TIterator, typename TValue, typename TCompare>
TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare) TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
{ {
typedef typename ETLSTD::iterator_traits<TIterator>::difference_type difference_t; typedef typename etlstd::iterator_traits<TIterator>::difference_type difference_t;
difference_t count = ETLSTD::distance(first, last); difference_t count = etlstd::distance(first, last);
while (count > 0) while (count > 0)
{ {
TIterator itr = first; TIterator itr = first;
difference_t step = count / 2; difference_t step = count / 2;
ETLSTD::advance(itr, step); etlstd::advance(itr, step);
if (!compare(value, *itr)) if (!compare(value, *itr))
{ {
@ -253,27 +331,27 @@ namespace ETLSTD
template<typename TIterator, typename TValue> template<typename TIterator, typename TValue>
TIterator upper_bound(TIterator first, TIterator last, const TValue& value) TIterator upper_bound(TIterator first, TIterator last, const TValue& value)
{ {
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator>::value_type> compare; typedef etlstd::less<typename etlstd::iterator_traits<TIterator>::value_type> compare;
return ETLSTD::upper_bound(first, last, value, compare()); return etlstd::upper_bound(first, last, value, compare());
} }
//*************************************************************************** //***************************************************************************
// equal_range // equal_range
template<typename TIterator, typename TValue, typename TCompare> template<typename TIterator, typename TValue, typename TCompare>
ETLSTD::pair <TIterator, TIterator> equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare) ETL_PAIR<TIterator, TIterator> equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare)
{ {
return ETLSTD::make_pair(ETLSTD::lower_bound(first, last, value, compare), return ETL_MAKE_PAIR(etlstd::lower_bound(first, last, value, compare),
ETLSTD::upper_bound(first, last, value, compare)); etlstd::upper_bound(first, last, value, compare));
} }
template<typename TIterator, typename TValue> template<typename TIterator, typename TValue>
ETLSTD::pair<TIterator, TIterator> equal_range(TIterator first, TIterator last, const TValue& value) ETL_PAIR<TIterator, TIterator> equal_range(TIterator first, TIterator last, const TValue& value)
{ {
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator>::value_type> compare; typedef etlstd::less<typename etlstd::iterator_traits<TIterator>::value_type> compare;
return ETLSTD::make_pair(ETLSTD::lower_bound(first, last, value, compare()), return ETL_MAKE_PAIR(etlstd::lower_bound(first, last, value, compare()),
ETLSTD::upper_bound(first, last, value, compare())); etlstd::upper_bound(first, last, value, compare()));
} }
//*************************************************************************** //***************************************************************************
@ -392,30 +470,10 @@ namespace ETLSTD
return n; return n;
} }
//***************************************************************************
// swap
template <typename T>
void swap(T& a, T& b)
{
T c = a;
a = b;
b = c;
}
//***************************************************************************
// iter_swap
template <typename TIterator1, typename TIterator2>
void iter_swap(TIterator1 a, TIterator2 b)
{
typename ETLSTD::iterator_traits<TIterator1>::value_type c = *a;
*a = *b;
*b = c;
}
//*************************************************************************** //***************************************************************************
// equal // equal
template <typename TIterator1, typename TIterator2> template <typename TIterator1, typename TIterator2>
typename etl::enable_if<!etl::is_pointer<TIterator1>::value || !etl::is_pointer<TIterator2>::value || !etl::is_pod<typename ETLSTD::iterator_traits<TIterator1>::value_type>::value, bool>::type typename etl::enable_if<!etl::is_pointer<TIterator1>::value || !etl::is_pointer<TIterator2>::value || !etl::is_pod<typename etlstd::iterator_traits<TIterator1>::value_type>::value, bool>::type
equal(TIterator1 first1, TIterator1 last1, TIterator2 first2) equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
{ {
while (first1 != last1) while (first1 != last1)
@ -430,12 +488,12 @@ namespace ETLSTD
} }
template <typename TIterator1, typename TIterator2> template <typename TIterator1, typename TIterator2>
typename etl::enable_if<etl::is_pointer<TIterator1>::value && etl::is_pointer<TIterator2>::value && etl::is_pod<typename ETLSTD::iterator_traits<TIterator1>::value_type>::value, bool>::type typename etl::enable_if<etl::is_pointer<TIterator1>::value && etl::is_pointer<TIterator2>::value && etl::is_pod<typename etlstd::iterator_traits<TIterator1>::value_type>::value, bool>::type
equal(TIterator1 first1, TIterator1 last1, TIterator2 first2) equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
{ {
typedef typename ETLSTD::iterator_traits<TIterator1>::value_type value_t; typedef typename etlstd::iterator_traits<TIterator1>::value_type value_t;
return (memcmp(first1, first2, sizeof(value_t) * (last1 - last1)) == 0); return (memcmp(first1, first2, sizeof(value_t) * (last1 - first1)) == 0);
} }
//*************************************************************************** //***************************************************************************
@ -470,9 +528,9 @@ namespace ETLSTD
bool lexicographical_compare(TIterator1 first1, TIterator1 last1, bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
TIterator2 first2, TIterator2 last2) TIterator2 first2, TIterator2 last2)
{ {
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator1>::value_type> compare; typedef etlstd::less<typename etlstd::iterator_traits<TIterator1>::value_type> compare;
return ETLSTD::lexicographical_compare(first1, last1, first2, last2, compare()); return etlstd::lexicographical_compare(first1, last1, first2, last2, compare());
} }
//*************************************************************************** //***************************************************************************
@ -486,9 +544,9 @@ namespace ETLSTD
template <typename T> template <typename T>
const T& min(const T& a, const T& b) const T& min(const T& a, const T& b)
{ {
typedef ETLSTD::less<T> compare; typedef etlstd::less<T> compare;
return ETLSTD::min(a, b, compare()); return etlstd::min(a, b, compare());
} }
//*************************************************************************** //***************************************************************************
@ -502,9 +560,9 @@ namespace ETLSTD
template <typename T> template <typename T>
const T& max(const T& a, const T& b) const T& max(const T& a, const T& b)
{ {
typedef ETLSTD::less<T> compare; typedef etlstd::less<T> compare;
return ETLSTD::max(a, b, compare()); return etlstd::max(a, b, compare());
} }
//*************************************************************************** //***************************************************************************
@ -606,8 +664,8 @@ namespace ETLSTD
template <typename TIterator, typename TCompare> template <typename TIterator, typename TCompare>
void pop_heap(TIterator first, TIterator last, TCompare compare) void pop_heap(TIterator first, TIterator last, TCompare compare)
{ {
typedef typename ETLSTD::iterator_traits<TIterator>::value_type value_t; typedef typename etlstd::iterator_traits<TIterator>::value_type value_t;
typedef typename ETLSTD::iterator_traits<TIterator>::difference_type distance_t; typedef typename etlstd::iterator_traits<TIterator>::difference_type distance_t;
value_t value = last[-1]; value_t value = last[-1];
last[-1] = first[0]; last[-1] = first[0];
@ -619,17 +677,17 @@ namespace ETLSTD
template <typename TIterator> template <typename TIterator>
void pop_heap(TIterator first, TIterator last) void pop_heap(TIterator first, TIterator last)
{ {
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator>::value_type> compare; typedef etlstd::less<typename etlstd::iterator_traits<TIterator>::value_type> compare;
ETLSTD::pop_heap(first, last, compare()); etlstd::pop_heap(first, last, compare());
} }
// Push Heap // Push Heap
template <typename TIterator, typename TCompare> template <typename TIterator, typename TCompare>
void push_heap(TIterator first, TIterator last, TCompare compare) void push_heap(TIterator first, TIterator last, TCompare compare)
{ {
typedef typename ETLSTD::iterator_traits<TIterator>::difference_type difference_t; typedef typename etlstd::iterator_traits<TIterator>::difference_type difference_t;
typedef typename ETLSTD::iterator_traits<TIterator>::value_type value_t; typedef typename etlstd::iterator_traits<TIterator>::value_type value_t;
private_heap::push_heap(first, difference_t(last - first - 1), difference_t(0), value_t(*(last - 1)), compare); private_heap::push_heap(first, difference_t(last - first - 1), difference_t(0), value_t(*(last - 1)), compare);
} }
@ -638,16 +696,16 @@ namespace ETLSTD
template <typename TIterator> template <typename TIterator>
void push_heap(TIterator first, TIterator last) void push_heap(TIterator first, TIterator last)
{ {
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator>::value_type> compare; typedef etlstd::less<typename etlstd::iterator_traits<TIterator>::value_type> compare;
ETLSTD::push_heap(first, last, compare()); etlstd::push_heap(first, last, compare());
} }
// Make Heap // Make Heap
template <typename TIterator, typename TCompare> template <typename TIterator, typename TCompare>
void make_heap(TIterator first, TIterator last, TCompare compare) void make_heap(TIterator first, TIterator last, TCompare compare)
{ {
typedef typename ETLSTD::iterator_traits<TIterator>::difference_type difference_t; typedef typename etlstd::iterator_traits<TIterator>::difference_type difference_t;
if ((last - first) < 2) if ((last - first) < 2)
{ {
@ -674,16 +732,16 @@ namespace ETLSTD
template <typename TIterator> template <typename TIterator>
void make_heap(TIterator first, TIterator last) void make_heap(TIterator first, TIterator last)
{ {
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator>::value_type> compare; typedef etlstd::less<typename etlstd::iterator_traits<TIterator>::value_type> compare;
ETLSTD::make_heap(first, last, compare()); etlstd::make_heap(first, last, compare());
} }
// Is Heap // Is Heap
template <typename TIterator> template <typename TIterator>
bool is_heap(TIterator first, TIterator last) bool is_heap(TIterator first, TIterator last)
{ {
typedef ETLSTD::less<typename ETLSTD::iterator_traits<TIterator>::value_type> compare; typedef etlstd::less<typename etlstd::iterator_traits<TIterator>::value_type> compare;
return private_heap::is_heap(first, last - first, compare()); return private_heap::is_heap(first, last - first, compare());
} }
@ -700,45 +758,43 @@ namespace ETLSTD
template<typename TIterator1, typename TIterator2, typename TCompare> template<typename TIterator1, typename TIterator2, typename TCompare>
TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare) TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare)
{ {
if (search_first == search_last) while (true)
{ {
return first; TIterator1 itr = first;
} TIterator2 search_itr = search_first;
while (first != last) while (true)
{
TIterator1 itr1 = first;
TIterator2 itr2 = search_first;
while (compare(*itr1,*itr2))
{ {
if (itr2 == search_last) if (search_itr == search_last)
{ {
return first; return first;
} }
if (itr1 == last) if (itr == last)
{ {
return last; return last;
} }
++itr1; if (!compare(*itr, *search_itr))
++itr2; {
break;
}
++itr;
++search_itr;
} }
++first; ++first;
} }
return last;
} }
// Search // Search
template<typename TIterator1, class TIterator2> template<typename TIterator1, class TIterator2>
TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last) TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last)
{ {
typedef ETLSTD::equal_to<typename ETLSTD::iterator_traits<TIterator1>::value_type> compare; typedef etlstd::equal_to<typename etlstd::iterator_traits<TIterator1>::value_type> compare;
return ETLSTD::search(first, last, search_first, search_last, compare()); return etlstd::search(first, last, search_first, search_last, compare());
} }
//*************************************************************************** //***************************************************************************
@ -750,7 +806,7 @@ namespace ETLSTD
while (first != next) while (first != next)
{ {
ETLSTD::swap(*first++, *next++); etlstd::swap(*first++, *next++);
if (next == last) if (next == last)
{ {
@ -764,6 +820,49 @@ namespace ETLSTD
return first; return first;
} }
//***************************************************************************
// find_end
// Predicate
template <typename TIterator1, typename TIterator2, typename TPredicate>
TIterator1 find_end(TIterator1 b, TIterator1 e,
TIterator2 sb, TIterator2 se,
TPredicate predicate)
{
if (sb == se)
{
return e;
}
TIterator1 result = e;
while (true)
{
TIterator1 new_result = etlstd::search(b, e, sb, se, predicate);
if (new_result == e)
{
break;
}
else
{
result = new_result;
b = result;
++b;
}
}
return result;
}
// Default
template <typename TIterator1, typename TIterator2>
TIterator1 find_end(TIterator1 b, TIterator1 e,
TIterator2 sb, TIterator2 se)
{
typedef etlstd::equal_to<typename etlstd::iterator_traits<TIterator1>::value_type> predicate;
return find_end(b, e, sb, se, predicate());
}
} }
#endif #endif

View File

@ -3,9 +3,11 @@
#define ETL_STL_ALTERNATE_FUNCTIONAL_INCLUDED #define ETL_STL_ALTERNATE_FUNCTIONAL_INCLUDED
#include "../../platform.h" #include "../../platform.h"
#include "choose_namespace.h"
namespace ETLSTD #include "../../private/choose_tag_types.h"
#include "../../private/choose_pair_types.h"
namespace etlstd
{ {
//*************************************************************************** //***************************************************************************
template <typename T = void> template <typename T = void>
@ -69,7 +71,7 @@ namespace ETLSTD
//*************************************************************************** //***************************************************************************
template <typename TFunction> template <typename TFunction>
class binder1st : public ETLSTD::unary_function<typename TFunction::second_argument_type, typename TFunction::result_type> class binder1st : public etlstd::unary_function<typename TFunction::second_argument_type, typename TFunction::result_type>
{ {
protected: protected:
@ -103,7 +105,7 @@ namespace ETLSTD
//*************************************************************************** //***************************************************************************
template <typename TFunction > template <typename TFunction >
class binder2nd : public ETLSTD::unary_function<typename TFunction::first_argument_type, typename TFunction::result_type> class binder2nd : public etlstd::unary_function<typename TFunction::first_argument_type, typename TFunction::result_type>
{ {
protected: protected:
TFunction operation; TFunction operation;

View File

@ -33,26 +33,15 @@ SOFTWARE.
#define ETL_STL_ALTERNATE_ITERATOR_INCLUDED #define ETL_STL_ALTERNATE_ITERATOR_INCLUDED
#include "../../platform.h" #include "../../platform.h"
#include <string.h>
#include "../../type_traits.h" #include "../../type_traits.h"
#include "choose_namespace.h" #include <string.h>
namespace ETLSTD #include "../../private/choose_tag_types.h"
#include "../../private/choose_pair_types.h"
namespace etlstd
{ {
//***************************************************************************
// iterator
template <typename TCategory, typename T, typename TDistance = ptrdiff_t, typename TPointer = T* , typename TReference = T&>
struct iterator
{
typedef T value_type;
typedef TDistance difference_type;
typedef TPointer pointer;
typedef TReference reference;
typedef TCategory iterator_category;
};
//*************************************************************************** //***************************************************************************
// iterator tags // iterator tags
struct input_iterator_tag {}; struct input_iterator_tag {};
@ -66,43 +55,37 @@ namespace ETLSTD
template <typename TIterator> template <typename TIterator>
struct iterator_traits struct iterator_traits
{ {
typedef typename TIterator::difference_type difference_type; typedef typename TIterator::iterator_category iterator_category;
typedef typename TIterator::value_type value_type; typedef typename TIterator::value_type value_type;
typedef typename TIterator::difference_type difference_type;
typedef typename TIterator::pointer pointer; typedef typename TIterator::pointer pointer;
typedef typename TIterator::reference reference; typedef typename TIterator::reference reference;
typedef typename TIterator::iterator_category iterator_category;
}; };
template <typename T> template <typename T>
struct iterator_traits<T*> struct iterator_traits<T*>
{ {
typedef ptrdiff_t difference_type; typedef ETL_RANDOM_ACCESS_ITERATOR_TAG iterator_category;
typedef T value_type; typedef T value_type;
typedef T* pointer; typedef ptrdiff_t difference_type;
typedef T& reference; typedef T* pointer;
typedef random_access_iterator_tag iterator_category; typedef T& reference;
}; };
template <typename T> template <typename T>
struct iterator_traits<const T*> struct iterator_traits<const T*>
{ {
typedef ptrdiff_t difference_type; typedef ETL_RANDOM_ACCESS_ITERATOR_TAG iterator_category;
typedef T value_type; typedef T value_type;
typedef T* pointer; typedef ptrdiff_t difference_type;
typedef T& reference; typedef const T* pointer;
typedef random_access_iterator_tag iterator_category; typedef const T& reference;
}; };
//*************************************************************************** //***************************************************************************
// advance // advance
template <typename TIterator, typename TDistance> template <typename TIterator, typename TDistance>
void advance(TIterator& itr, TDistance n) ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_INPUT_ITERATOR_TAG)
{
advance_helper(itr, n, typename ETLSTD::iterator_traits<TIterator>::iterator_category());
}
template <typename TIterator, typename TDistance>
void advance_helper(TIterator& itr, TDistance n, ETLSTD::input_iterator_tag)
{ {
while (n--) while (n--)
{ {
@ -111,7 +94,7 @@ namespace ETLSTD
} }
template <typename TIterator, typename TDistance> template <typename TIterator, typename TDistance>
void advance_helper(TIterator& itr, TDistance n, ETLSTD::output_iterator_tag) ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_OUTPUT_ITERATOR_TAG)
{ {
while (n--) while (n--)
{ {
@ -120,7 +103,7 @@ namespace ETLSTD
} }
template <typename TIterator, typename TDistance> template <typename TIterator, typename TDistance>
void advance_helper(TIterator& itr, TDistance n, ETLSTD::forward_iterator_tag) ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_FORWARD_ITERATOR_TAG)
{ {
while (n--) while (n--)
{ {
@ -129,7 +112,7 @@ namespace ETLSTD
} }
template <typename TIterator, typename TDistance> template <typename TIterator, typename TDistance>
void advance_helper(TIterator& itr, TDistance n, ETLSTD::bidirectional_iterator_tag) ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_BIDIRECTIONAL_ITERATOR_TAG)
{ {
if (n > 0) if (n > 0)
{ {
@ -148,23 +131,25 @@ namespace ETLSTD
} }
template <typename TIterator, typename TDistance> template <typename TIterator, typename TDistance>
void advance_helper(TIterator& itr, TDistance n, ETLSTD::random_access_iterator_tag) ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_RANDOM_ACCESS_ITERATOR_TAG)
{ {
itr += n; itr += n;
} }
template <typename TIterator, typename TDistance>
ETL_CONSTEXPR17 void advance(TIterator& itr, TDistance n)
{
typedef typename etlstd::iterator_traits<TIterator>::iterator_category tag;
advance_helper(itr, n, tag());
}
//*************************************************************************** //***************************************************************************
// distance // distance
template<typename TIterator> template<typename TIterator>
typename ETLSTD::iterator_traits<TIterator>::difference_type distance(TIterator first, TIterator last) ETL_CONSTEXPR17 typename etlstd::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETL_INPUT_ITERATOR_TAG)
{ {
return distance_helper(first, last, typename ETLSTD::iterator_traits<TIterator>::iterator_category()); typename etlstd::iterator_traits<TIterator>::difference_type d = 0;
}
template<typename TIterator>
typename ETLSTD::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETLSTD::input_iterator_tag)
{
typename ETLSTD::iterator_traits<TIterator>::difference_type d = 0;
while (first != last) while (first != last)
{ {
@ -176,9 +161,9 @@ namespace ETLSTD
} }
template<typename TIterator> template<typename TIterator>
typename ETLSTD::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETLSTD::forward_iterator_tag) ETL_CONSTEXPR17 typename etlstd::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETL_FORWARD_ITERATOR_TAG)
{ {
typename ETLSTD::iterator_traits<TIterator>::difference_type d = 0; typename etlstd::iterator_traits<TIterator>::difference_type d = 0;
while (first != last) while (first != last)
{ {
@ -190,9 +175,9 @@ namespace ETLSTD
} }
template<typename TIterator> template<typename TIterator>
typename ETLSTD::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETLSTD::bidirectional_iterator_tag) ETL_CONSTEXPR17 typename etlstd::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETL_BIDIRECTIONAL_ITERATOR_TAG)
{ {
typename ETLSTD::iterator_traits<TIterator>::difference_type d = 0; typename etlstd::iterator_traits<TIterator>::difference_type d = 0;
while (first != last) while (first != last)
{ {
@ -204,122 +189,134 @@ namespace ETLSTD
} }
template<typename TIterator> template<typename TIterator>
typename ETLSTD::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETLSTD::random_access_iterator_tag) ETL_CONSTEXPR17 typename etlstd::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETL_RANDOM_ACCESS_ITERATOR_TAG)
{ {
return last - first; return last - first;
} }
template<typename TIterator>
ETL_CONSTEXPR17 typename etlstd::iterator_traits<TIterator>::difference_type distance(TIterator first, TIterator last)
{
typedef typename etlstd::iterator_traits<TIterator>::iterator_category tag;
return distance_helper(first, last, tag());
}
//*************************************************************************** //***************************************************************************
// reverse_iterator // reverse_iterator
template <typename TIterator> template <typename TIterator>
struct reverse_iterator class reverse_iterator
{ {
public: public:
typedef typename ETLSTD::iterator_traits<TIterator>::difference_type difference_type; typedef typename iterator_traits<TIterator>::iterator_category iterator_category;
typedef typename ETLSTD::iterator_traits<TIterator>::value_type value_type; typedef typename iterator_traits<TIterator>::value_type value_type;
typedef typename ETLSTD::iterator_traits<TIterator>::pointer pointer; typedef typename iterator_traits<TIterator>::difference_type difference_type;
typedef typename ETLSTD::iterator_traits<TIterator>::reference reference; typedef typename iterator_traits<TIterator>::pointer pointer;
typedef typename ETLSTD::iterator_traits<TIterator>::iterator_category iterator_category; typedef typename iterator_traits<TIterator>::reference reference;
reverse_iterator() typedef TIterator iterator_type;
ETL_CONSTEXPR17 reverse_iterator()
: current()
{ {
} }
explicit reverse_iterator(TIterator itr) : current(--itr) ETL_CONSTEXPR17 explicit reverse_iterator(TIterator itr)
: current(itr)
{ {
} }
reverse_iterator(const reverse_iterator<TIterator>& itr) template <typename TOther>
: current(itr.current) ETL_CONSTEXPR17 reverse_iterator(const reverse_iterator<TOther>& other)
: current(other.base())
{ {
} }
template <typename UITerator> template<class TOther>
reverse_iterator(const reverse_iterator<UITerator>& itr) ETL_CONSTEXPR17 reverse_iterator& operator=(const reverse_iterator<TOther>& other)
: current(itr.base())
{ {
current = other.base();
return (*this);
} }
reverse_iterator<TIterator>& operator = (const reverse_iterator<TIterator>& itr) ETL_CONSTEXPR17 TIterator base() const
{
current = itr.base();
return *this;
}
template <typename UITerator>
reverse_iterator<TIterator>& operator = (const reverse_iterator<UITerator>& itr)
{
current = itr.base();
return *this;
}
TIterator base() const
{ {
return current; return current;
} }
reference operator *() const ETL_NODISCARD ETL_CONSTEXPR17 reference operator*() const
{ {
return *current; TIterator temp = current;
return *(--temp);
} }
pointer operator ->() const ETL_NODISCARD ETL_CONSTEXPR17 pointer operator->() const
{ {
return &(*current); TIterator temp = current;
return &(*--temp);
} }
reverse_iterator<TIterator>& operator ++() ETL_CONSTEXPR17 reverse_iterator& operator++()
{ {
--current; --current;
return *this; return *this;
} }
reverse_iterator<TIterator> operator ++(int) ETL_CONSTEXPR17 reverse_iterator operator++(int)
{ {
reverse_iterator<TIterator> temp = *this; reverse_iterator temp = *this;
--current; --current;
return temp; return temp;
} }
reverse_iterator<TIterator>& operator --() ETL_CONSTEXPR17 reverse_iterator& operator--()
{ {
++current; ++current;
return *this;
return (*this);
} }
reverse_iterator<TIterator> operator --(int) ETL_CONSTEXPR17 reverse_iterator operator--(int)
{ {
reverse_iterator<TIterator> temp = *this; reverse_iterator temp = *this;
++current; ++current;
return temp; return temp;
} }
reverse_iterator<TIterator> operator +(difference_type n) const ETL_CONSTEXPR17 reverse_iterator& operator+=(const difference_type offset)
{ {
return reverse_iterator<TIterator>(current - n); current -= offset;
return (*this);
} }
reverse_iterator<TIterator>& operator +=(difference_type n) ETL_CONSTEXPR17 reverse_iterator& operator-=(const difference_type offset)
{ {
current -= n; current += offset;
return *this;
return (*this);
} }
reverse_iterator<TIterator> operator -(difference_type n) const ETL_NODISCARD ETL_CONSTEXPR17 reverse_iterator operator+(const difference_type offset) const
{ {
return reverse_iterator<TIterator>(current + n); return reverse_iterator(current - offset);
} }
reverse_iterator<TIterator>& operator -=(difference_type n) ETL_NODISCARD ETL_CONSTEXPR17 reverse_iterator operator-(const difference_type offset) const
{ {
current += n; return (reverse_iterator(current + offset));
return *this;
} }
reference operator [](difference_type n) const ETL_NODISCARD ETL_CONSTEXPR17 reference operator[](const difference_type offset) const
{ {
return *(current - n); return (*(*this + offset));
} }
protected: protected:
@ -328,49 +325,49 @@ namespace ETLSTD
}; };
template <class TIterator> template <class TIterator>
inline bool operator ==(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs) inline ETL_CONSTEXPR17 bool operator ==(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs)
{ {
return lhs.base() == rhs.base(); return lhs.base() == rhs.base();
} }
template <class TIterator> template <class TIterator>
inline bool operator !=(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs) inline ETL_CONSTEXPR17 bool operator !=(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs)
{ {
return !(lhs == rhs); return !(lhs == rhs);
} }
template <class TIterator> template <class TIterator>
inline bool operator <(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs) inline ETL_CONSTEXPR17 bool operator <(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs)
{ {
return rhs.base() < lhs.base(); return rhs.base() < lhs.base();
} }
template <class TIterator> template <class TIterator>
inline bool operator >(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs) inline ETL_CONSTEXPR17 bool operator >(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs)
{ {
return rhs < lhs; return rhs < lhs;
} }
template <class TIterator> template <class TIterator>
inline bool operator <=(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs) inline ETL_CONSTEXPR17 bool operator <=(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs)
{ {
return !(rhs < lhs); return !(rhs < lhs);
} }
template <class TIterator> template <class TIterator>
inline bool operator >=(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs) inline ETL_CONSTEXPR17 bool operator >=(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs)
{ {
return !(lhs < rhs); return !(lhs < rhs);
} }
template <class TIterator> template <class TIterator>
inline typename reverse_iterator<TIterator>::difference_type operator -(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs) inline ETL_CONSTEXPR17 typename reverse_iterator<TIterator>::difference_type operator -(const reverse_iterator<TIterator>& lhs, const reverse_iterator<TIterator>& rhs)
{ {
return rhs.base() - lhs.base(); return rhs.base() - lhs.base();
} }
template <class TIterator, class TDifference> template <class TIterator, class TDifference>
inline reverse_iterator<TIterator> operator +(TDifference n, const reverse_iterator<TIterator>& itr) inline ETL_CONSTEXPR17 reverse_iterator<TIterator> operator +(TDifference n, const reverse_iterator<TIterator>& itr)
{ {
return itr.operator +(n); return itr.operator +(n);
} }
@ -378,18 +375,18 @@ namespace ETLSTD
//*************************************************************************** //***************************************************************************
// Previous // Previous
template<typename TIterator> template<typename TIterator>
TIterator prev(TIterator itr, typename ETLSTD::iterator_traits<TIterator>::difference_type n = 1) ETL_CONSTEXPR17 TIterator prev(TIterator itr, typename etlstd::iterator_traits<TIterator>::difference_type n = 1)
{ {
ETLSTD::advance(itr, -n); etlstd::advance(itr, -n);
return itr; return itr;
} }
//*************************************************************************** //***************************************************************************
// Next // Next
template<typename TIterator> template<typename TIterator>
TIterator next(TIterator itr, typename ETLSTD::iterator_traits<TIterator>::difference_type n = 1) ETL_CONSTEXPR17 TIterator next(TIterator itr, typename etlstd::iterator_traits<TIterator>::difference_type n = 1)
{ {
ETLSTD::advance(itr, n); etlstd::advance(itr, n);
return itr; return itr;
} }
} }

View File

@ -36,7 +36,8 @@ SOFTWARE.
#include "../../char_traits.h" #include "../../char_traits.h"
#include "../../integral_limits.h" #include "../../integral_limits.h"
#include "choose_namespace.h" #include "../../private/choose_tag_types.h"
#include "../../private/choose_pair_types.h"
#include <limits.h> #include <limits.h>
#include <stdint.h> #include <stdint.h>
@ -44,7 +45,7 @@ SOFTWARE.
#define ETL_LOG2(x) (((x) * 301) / 1000) #define ETL_LOG2(x) (((x) * 301) / 1000)
namespace ETLSTD namespace etlstd
{ {
template<class T> class numeric_limits; template<class T> class numeric_limits;
@ -70,70 +71,70 @@ namespace ETLSTD
class etl_integral_type class etl_integral_type
{ {
public: public:
static const bool is_specialized; static ETL_CONST bool is_specialized = true;
static const int max_digits10; static ETL_CONST int max_digits10 = 0;
static const bool is_integer; static ETL_CONST bool is_integer = true;
static const bool is_exact; static ETL_CONST bool is_exact = true;
static const int radix; static ETL_CONST int radix = 2;
static ETL_CONSTEXPR T epsilon() { return 0; } static ETL_CONSTEXPR T epsilon() { return 0; }
static ETL_CONSTEXPR T round_error() { return 0; } static ETL_CONSTEXPR T round_error() { return 0; }
static const int digits; static ETL_CONST int digits = (CHAR_BIT * sizeof(T)) - (etl::is_signed<T>::value ? 1 : 0);
static const int digits10; static ETL_CONST int digits10 = ETL_LOG2(digits);
static const bool is_signed; static ETL_CONST bool is_signed = etl::is_signed<T>::value;
static const int min_exponent; static ETL_CONST int min_exponent = 0;
static const int min_exponent10; static ETL_CONST int min_exponent10 = 0;
static const int max_exponent; static ETL_CONST int max_exponent = 0;
static const int max_exponent10; static ETL_CONST int max_exponent10 = 0;
static const bool has_infinity; static ETL_CONST bool has_infinity = false;
static const bool has_quiet_NaN; static ETL_CONST bool has_quiet_NaN = false;
static const bool has_signaling_NaN; static ETL_CONST bool has_signaling_NaN = false;
static const float_denorm_style has_denorm; static ETL_CONST float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss; static ETL_CONST bool has_denorm_loss = false;
static ETL_CONSTEXPR T infinity() { return 0; } static ETL_CONSTEXPR T infinity() { return 0; }
static ETL_CONSTEXPR T quiet_NaN() { return 0; } static ETL_CONSTEXPR T quiet_NaN() { return 0; }
static ETL_CONSTEXPR T signaling_NaN() { return 0; } static ETL_CONSTEXPR T signaling_NaN() { return 0; }
static ETL_CONSTEXPR T denorm_min() { return 0; } static ETL_CONSTEXPR T denorm_min() { return 0; }
static const bool is_iec559; static ETL_CONST bool is_iec559 = false;
static const bool is_bounded; static ETL_CONST bool is_bounded = true;
static const bool is_modulo; static ETL_CONST bool is_modulo = etl::is_unsigned<T>::value;
static const bool traps; static ETL_CONST bool traps = false;
static const bool tinyness_before; static ETL_CONST bool tinyness_before = false;
static const float_round_style round_style; static ETL_CONST float_round_style round_style = round_toward_zero;
}; };
template <typename T> const bool etl_integral_type<T>::is_specialized = true; template <typename T> ETL_CONST bool etl_integral_type<T>::is_specialized;
template <typename T> const int etl_integral_type<T>::digits = (CHAR_BIT * sizeof(T)) - (etl::is_signed<T>::value ? 1 : 0); template <typename T> ETL_CONST int etl_integral_type<T>::digits;
template <typename T> const int etl_integral_type<T>::digits10 = ETL_LOG2(digits); template <typename T> ETL_CONST int etl_integral_type<T>::digits10;
template <typename T> const int etl_integral_type<T>::max_digits10 = 0; template <typename T> ETL_CONST int etl_integral_type<T>::max_digits10;
template <typename T> const bool etl_integral_type<T>::is_signed = etl::is_signed<T>::value; template <typename T> ETL_CONST bool etl_integral_type<T>::is_signed;
template <typename T> const bool etl_integral_type<T>::is_integer = true; template <typename T> ETL_CONST bool etl_integral_type<T>::is_integer;
template <typename T> const bool etl_integral_type<T>::is_exact = true; template <typename T> ETL_CONST bool etl_integral_type<T>::is_exact;
template <typename T> const int etl_integral_type<T>::radix = 2; template <typename T> ETL_CONST int etl_integral_type<T>::radix;
template <typename T> const int etl_integral_type<T>::min_exponent = 0; template <typename T> ETL_CONST int etl_integral_type<T>::min_exponent;
template <typename T> const int etl_integral_type<T>::min_exponent10 = 0; template <typename T> ETL_CONST int etl_integral_type<T>::min_exponent10;
template <typename T> const int etl_integral_type<T>::max_exponent = 0; template <typename T> ETL_CONST int etl_integral_type<T>::max_exponent;
template <typename T> const int etl_integral_type<T>::max_exponent10 = 0; template <typename T> ETL_CONST int etl_integral_type<T>::max_exponent10;
template <typename T> const bool etl_integral_type<T>::has_infinity = false; template <typename T> ETL_CONST bool etl_integral_type<T>::has_infinity;
template <typename T> const bool etl_integral_type<T>::has_quiet_NaN = false; template <typename T> ETL_CONST bool etl_integral_type<T>::has_quiet_NaN;
template <typename T> const bool etl_integral_type<T>::has_signaling_NaN = false; template <typename T> ETL_CONST bool etl_integral_type<T>::has_signaling_NaN;
template <typename T> const float_denorm_style etl_integral_type<T>::has_denorm = denorm_absent; template <typename T> ETL_CONST float_denorm_style etl_integral_type<T>::has_denorm;
template <typename T> const bool etl_integral_type<T>::has_denorm_loss = false; template <typename T> ETL_CONST bool etl_integral_type<T>::has_denorm_loss;
template <typename T> const bool etl_integral_type<T>::is_iec559 = false; template <typename T> ETL_CONST bool etl_integral_type<T>::is_iec559;
template <typename T> const bool etl_integral_type<T>::is_bounded = true; template <typename T> ETL_CONST bool etl_integral_type<T>::is_bounded;
template <typename T> const bool etl_integral_type<T>::is_modulo = etl::is_unsigned<T>::value; template <typename T> ETL_CONST bool etl_integral_type<T>::is_modulo;
template <typename T> const bool etl_integral_type<T>::traps = false; template <typename T> ETL_CONST bool etl_integral_type<T>::traps;
template <typename T> const bool etl_integral_type<T>::tinyness_before = false; template <typename T> ETL_CONST bool etl_integral_type<T>::tinyness_before;
template <typename T> const float_round_style etl_integral_type<T>::round_style = round_toward_zero; template <typename T> ETL_CONST float_round_style etl_integral_type<T>::round_style;
//*************************************************************************** //***************************************************************************
// Base for floating point types. // Base for floating point types.
@ -141,50 +142,50 @@ namespace ETLSTD
class etl_floating_point_type class etl_floating_point_type
{ {
public: public:
static const bool is_specialized; static ETL_CONST bool is_specialized = true;
static const bool is_signed; static ETL_CONST bool is_signed = true;
static const bool is_integer; static ETL_CONST bool is_integer = false;
static const bool is_exact; static ETL_CONST bool is_exact = false;
static const int radix; static ETL_CONST int radix = 2;
static const bool has_infinity; static ETL_CONST bool has_infinity = false;
static const bool has_quiet_NaN; static ETL_CONST bool has_quiet_NaN = false;
static const bool has_signaling_NaN; static ETL_CONST bool has_signaling_NaN = false;
static const float_denorm_style has_denorm; static ETL_CONST float_denorm_style has_denorm = denorm_present;
static const bool has_denorm_loss; static ETL_CONST bool has_denorm_loss = true;
static const bool is_iec559; static ETL_CONST bool is_iec559 = true;
static const bool is_bounded; static ETL_CONST bool is_bounded = true;
static const bool is_modulo; static ETL_CONST bool is_modulo = false;
static ETL_CONSTEXPR T round_error() { return T(0.5); } static ETL_CONSTEXPR T round_error() { return T(0.5); }
static ETL_CONSTEXPR T infinity() { return 0; } static ETL_CONSTEXPR T infinity() { return 0; }
static ETL_CONSTEXPR T quiet_NaN() { return 0; } static ETL_CONSTEXPR T quiet_NaN() { return 0; }
static ETL_CONSTEXPR T signaling_NaN() { return 0; } static ETL_CONSTEXPR T signaling_NaN() { return 0; }
static const bool traps; static ETL_CONST bool traps = false;
static const bool tinyness_before; static ETL_CONST bool tinyness_before = true;
static const float_round_style round_style; static ETL_CONST float_round_style round_style = round_to_nearest;
}; };
template <typename T> const bool etl_floating_point_type<T>::is_specialized = true; template <typename T> ETL_CONST bool etl_floating_point_type<T>::is_specialized;
template <typename T> const bool etl_floating_point_type<T>::is_signed = true; template <typename T> ETL_CONST bool etl_floating_point_type<T>::is_signed;
template <typename T> const bool etl_floating_point_type<T>::is_integer = false; template <typename T> ETL_CONST bool etl_floating_point_type<T>::is_integer;
template <typename T> const bool etl_floating_point_type<T>::is_exact = false; template <typename T> ETL_CONST bool etl_floating_point_type<T>::is_exact;
template <typename T> const int etl_floating_point_type<T>::radix = 2; template <typename T> ETL_CONST int etl_floating_point_type<T>::radix;
template <typename T> const bool etl_floating_point_type<T>::has_infinity = false; template <typename T> ETL_CONST bool etl_floating_point_type<T>::has_infinity;
template <typename T> const bool etl_floating_point_type<T>::has_quiet_NaN = false; template <typename T> ETL_CONST bool etl_floating_point_type<T>::has_quiet_NaN;
template <typename T> const bool etl_floating_point_type<T>::has_signaling_NaN = false; template <typename T> ETL_CONST bool etl_floating_point_type<T>::has_signaling_NaN;
template <typename T> const float_denorm_style etl_floating_point_type<T>::has_denorm = denorm_present; template <typename T> ETL_CONST float_denorm_style etl_floating_point_type<T>::has_denorm;
template <typename T> const bool etl_floating_point_type<T>::has_denorm_loss = true; template <typename T> ETL_CONST bool etl_floating_point_type<T>::has_denorm_loss;
template <typename T> const bool etl_floating_point_type<T>::is_iec559 = true; template <typename T> ETL_CONST bool etl_floating_point_type<T>::is_iec559;
template <typename T> const bool etl_floating_point_type<T>::is_bounded = true; template <typename T> ETL_CONST bool etl_floating_point_type<T>::is_bounded;
template <typename T> const bool etl_floating_point_type<T>::is_modulo = false; template <typename T> ETL_CONST bool etl_floating_point_type<T>::is_modulo;
template <typename T> const bool etl_floating_point_type<T>::traps = false; template <typename T> ETL_CONST bool etl_floating_point_type<T>::traps;
template <typename T> const bool etl_floating_point_type<T>::tinyness_before = true; template <typename T> ETL_CONST bool etl_floating_point_type<T>::tinyness_before;
template <typename T> const float_round_style etl_floating_point_type<T>::round_style = round_to_nearest; template <typename T> ETL_CONST float_round_style etl_floating_point_type<T>::round_style;
//*************************************************************************** //***************************************************************************
// Default // Default
@ -198,72 +199,72 @@ namespace ETLSTD
{ {
public: public:
static const bool is_specialized; static ETL_CONST bool is_specialized = true;
static ETL_CONSTEXPR bool min() { return false; } static ETL_CONSTEXPR bool min() { return false; }
static ETL_CONSTEXPR bool max() { return true; } static ETL_CONSTEXPR bool max() { return true; }
static ETL_CONSTEXPR bool lowest() { return false; } static ETL_CONSTEXPR bool lowest() { return false; }
static const int digits; static ETL_CONST int digits = 1;
static const int digits10; static ETL_CONST int digits10 = 0;
static const int max_digits10; static ETL_CONST int max_digits10 = 0;
static const bool is_signed; static ETL_CONST bool is_signed = false;
static const bool is_integer; static ETL_CONST bool is_integer = true;
static const bool is_exact; static ETL_CONST bool is_exact = true;
static const int radix; static ETL_CONST int radix = 2;
static const bool epsilon() { return 0; } static ETL_CONST bool epsilon() { return 0; }
static const bool round_error() { return 0; } static ETL_CONST bool round_error() { return 0; }
static const int min_exponent; static ETL_CONST int min_exponent = 0;
static const int min_exponent10; static ETL_CONST int min_exponent10 = 0;
static const int max_exponent; static ETL_CONST int max_exponent = 0;
static const int max_exponent10; static ETL_CONST int max_exponent10 = 0;
static const bool has_infinity; static ETL_CONST bool has_infinity = false;
static const bool has_quiet_NaN; static ETL_CONST bool has_quiet_NaN = false;
static const bool has_signaling_NaN; static ETL_CONST bool has_signaling_NaN = false;
static const float_denorm_style has_denorm; static ETL_CONST float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss; static ETL_CONST bool has_denorm_loss = false;
static ETL_CONSTEXPR bool infinity() { return 0; } static ETL_CONSTEXPR bool infinity() { return 0; }
static ETL_CONSTEXPR bool quiet_NaN() { return 0; } static ETL_CONSTEXPR bool quiet_NaN() { return 0; }
static ETL_CONSTEXPR bool signaling_NaN() { return 0; } static ETL_CONSTEXPR bool signaling_NaN() { return 0; }
static ETL_CONSTEXPR bool denorm_min() { return 0; } static ETL_CONSTEXPR bool denorm_min() { return 0; }
static const bool is_iec559; static ETL_CONST bool is_iec559 = false;
static const bool is_bounded; static ETL_CONST bool is_bounded = true;
static const bool is_modulo; static ETL_CONST bool is_modulo = false;
static const bool traps; static ETL_CONST bool traps = false;
static const bool tinyness_before; static ETL_CONST bool tinyness_before = false;
static const float_round_style round_style; static ETL_CONST float_round_style round_style = round_toward_zero;
}; };
const bool numeric_limits<bool>::is_specialized = true; ETL_CONST bool numeric_limits<bool>::is_specialized;
const int numeric_limits<bool>::digits = 1; ETL_CONST int numeric_limits<bool>::digits;
const int numeric_limits<bool>::digits10 = 0; ETL_CONST int numeric_limits<bool>::digits10;
const int numeric_limits<bool>::max_digits10 = 0; ETL_CONST int numeric_limits<bool>::max_digits10;
const bool numeric_limits<bool>::is_signed = false; ETL_CONST bool numeric_limits<bool>::is_signed;
const bool numeric_limits<bool>::is_integer = true; ETL_CONST bool numeric_limits<bool>::is_integer;
const bool numeric_limits<bool>::is_exact = true; ETL_CONST bool numeric_limits<bool>::is_exact;
const int numeric_limits<bool>::radix = 2; ETL_CONST int numeric_limits<bool>::radix;
const int numeric_limits<bool>::min_exponent = 0; ETL_CONST int numeric_limits<bool>::min_exponent;
const int numeric_limits<bool>::min_exponent10 = 0; ETL_CONST int numeric_limits<bool>::min_exponent10;
const int numeric_limits<bool>::max_exponent = 0; ETL_CONST int numeric_limits<bool>::max_exponent;
const int numeric_limits<bool>::max_exponent10 = 0; ETL_CONST int numeric_limits<bool>::max_exponent10;
const bool numeric_limits<bool>::has_infinity = false; ETL_CONST bool numeric_limits<bool>::has_infinity;
const bool numeric_limits<bool>::has_quiet_NaN = false; ETL_CONST bool numeric_limits<bool>::has_quiet_NaN;
const bool numeric_limits<bool>::has_signaling_NaN = false; ETL_CONST bool numeric_limits<bool>::has_signaling_NaN;
const float_denorm_style numeric_limits<bool>::has_denorm = denorm_absent; ETL_CONST float_denorm_style numeric_limits<bool>::has_denorm;
const bool numeric_limits<bool>::has_denorm_loss = false; ETL_CONST bool numeric_limits<bool>::has_denorm_loss;
const bool numeric_limits<bool>::is_iec559 = false; ETL_CONST bool numeric_limits<bool>::is_iec559;
const bool numeric_limits<bool>::is_bounded = true; ETL_CONST bool numeric_limits<bool>::is_bounded;
const bool numeric_limits<bool>::is_modulo = false; ETL_CONST bool numeric_limits<bool>::is_modulo;
const bool numeric_limits<bool>::traps = false; ETL_CONST bool numeric_limits<bool>::traps;
const bool numeric_limits<bool>::tinyness_before = false; ETL_CONST bool numeric_limits<bool>::tinyness_before;
const float_round_style numeric_limits<bool>::round_style = round_toward_zero; ETL_CONST float_round_style numeric_limits<bool>::round_style;
//*************************************************************************** //***************************************************************************
// char // char
@ -446,23 +447,23 @@ namespace ETLSTD
static ETL_CONSTEXPR float epsilon() { return FLT_EPSILON; } static ETL_CONSTEXPR float epsilon() { return FLT_EPSILON; }
static ETL_CONSTEXPR float denorm_min() { return FLT_MIN; } static ETL_CONSTEXPR float denorm_min() { return FLT_MIN; }
static const int digits; static ETL_CONST int digits = FLT_MANT_DIG;
static const int digits10; static ETL_CONST int digits10 = FLT_DIG;
static const int max_digits10; static ETL_CONST int max_digits10 = ETL_LOG2(FLT_MANT_DIG) + 2;
static const int min_exponent; static ETL_CONST int min_exponent = FLT_MIN_EXP;
static const int min_exponent10; static ETL_CONST int min_exponent10 = FLT_MIN_10_EXP;
static const int max_exponent; static ETL_CONST int max_exponent = FLT_MAX_EXP;
static const int max_exponent10; static ETL_CONST int max_exponent10 = FLT_MAX_10_EXP;
}; };
const int numeric_limits<float>::digits = FLT_MANT_DIG; ETL_CONST int numeric_limits<float>::digits;
const int numeric_limits<float>::max_digits10 = ETL_LOG2(FLT_MANT_DIG) + 2; ETL_CONST int numeric_limits<float>::max_digits10;
const int numeric_limits<float>::digits10 = FLT_DIG; ETL_CONST int numeric_limits<float>::digits10;
const int numeric_limits<float>::min_exponent = FLT_MIN_EXP; ETL_CONST int numeric_limits<float>::min_exponent;
const int numeric_limits<float>::min_exponent10 = FLT_MIN_10_EXP; ETL_CONST int numeric_limits<float>::min_exponent10;
const int numeric_limits<float>::max_exponent = FLT_MAX_EXP; ETL_CONST int numeric_limits<float>::max_exponent;
const int numeric_limits<float>::max_exponent10 = FLT_MAX_10_EXP; ETL_CONST int numeric_limits<float>::max_exponent10;
//*************************************************************************** //***************************************************************************
// double // double
@ -477,23 +478,23 @@ namespace ETLSTD
static ETL_CONSTEXPR double epsilon() { return DBL_EPSILON; } static ETL_CONSTEXPR double epsilon() { return DBL_EPSILON; }
static ETL_CONSTEXPR double denorm_min() { return DBL_MIN; } static ETL_CONSTEXPR double denorm_min() { return DBL_MIN; }
static const int digits; static ETL_CONST int digits = DBL_MANT_DIG;
static const int digits10; static ETL_CONST int digits10 = DBL_DIG;
static const int max_digits10; static ETL_CONST int max_digits10 = ETL_LOG2(DBL_MANT_DIG) + 2;
static const int min_exponent; static ETL_CONST int min_exponent = DBL_MIN_EXP;
static const int min_exponent10; static ETL_CONST int min_exponent10 = DBL_MIN_10_EXP;
static const int max_exponent; static ETL_CONST int max_exponent = DBL_MAX_EXP;
static const int max_exponent10; static ETL_CONST int max_exponent10 = DBL_MAX_10_EXP;
}; };
const int numeric_limits<double>::digits = DBL_MANT_DIG; ETL_CONST int numeric_limits<double>::digits;
const int numeric_limits<double>::max_digits10 = ETL_LOG2(DBL_MANT_DIG) + 2; ETL_CONST int numeric_limits<double>::max_digits10;
const int numeric_limits<double>::digits10 = DBL_DIG; ETL_CONST int numeric_limits<double>::digits10;
const int numeric_limits<double>::min_exponent = DBL_MIN_EXP; ETL_CONST int numeric_limits<double>::min_exponent;
const int numeric_limits<double>::min_exponent10 = DBL_MIN_10_EXP; ETL_CONST int numeric_limits<double>::min_exponent10;
const int numeric_limits<double>::max_exponent = DBL_MAX_EXP; ETL_CONST int numeric_limits<double>::max_exponent;
const int numeric_limits<double>::max_exponent10 = DBL_MAX_10_EXP; ETL_CONST int numeric_limits<double>::max_exponent10;
//*************************************************************************** //***************************************************************************
// long double // long double
@ -508,23 +509,23 @@ namespace ETLSTD
static ETL_CONSTEXPR long double epsilon() { return LDBL_EPSILON; } static ETL_CONSTEXPR long double epsilon() { return LDBL_EPSILON; }
static ETL_CONSTEXPR long double denorm_min() { return LDBL_MIN; } static ETL_CONSTEXPR long double denorm_min() { return LDBL_MIN; }
static const int digits; static ETL_CONST int digits = LDBL_MANT_DIG;
static const int digits10; static ETL_CONST int digits10 = LDBL_DIG;
static const int max_digits10; static ETL_CONST int max_digits10 = ETL_LOG2(LDBL_MANT_DIG) + 2;
static const int min_exponent; static ETL_CONST int min_exponent = LDBL_MIN_EXP;
static const int min_exponent10; static ETL_CONST int min_exponent10 = LDBL_MIN_10_EXP;
static const int max_exponent; static ETL_CONST int max_exponent = LDBL_MAX_EXP;
static const int max_exponent10; static ETL_CONST int max_exponent10 = LDBL_MAX_10_EXP;
}; };
const int numeric_limits<long double>::digits = LDBL_MANT_DIG; ETL_CONST int numeric_limits<long double>::digits;
const int numeric_limits<long double>::max_digits10 = ETL_LOG2(LDBL_MANT_DIG) + 2; ETL_CONST int numeric_limits<long double>::max_digits10;
const int numeric_limits<long double>::digits10 = LDBL_DIG; ETL_CONST int numeric_limits<long double>::digits10;
const int numeric_limits<long double>::min_exponent = LDBL_MIN_EXP; ETL_CONST int numeric_limits<long double>::min_exponent;
const int numeric_limits<long double>::min_exponent10 = LDBL_MIN_10_EXP; ETL_CONST int numeric_limits<long double>::min_exponent10;
const int numeric_limits<long double>::max_exponent = LDBL_MAX_EXP; ETL_CONST int numeric_limits<long double>::max_exponent;
const int numeric_limits<long double>::max_exponent10 = LDBL_MAX_10_EXP; ETL_CONST int numeric_limits<long double>::max_exponent10;
} }
#endif #endif

View File

@ -34,9 +34,10 @@ SOFTWARE.
#include "../../platform.h" #include "../../platform.h"
#include "../../type_traits.h" #include "../../type_traits.h"
#include "choose_namespace.h" #include "../../private/choose_tag_types.h"
#include "../../private/choose_pair_types.h"
namespace ETLSTD namespace etlstd
{ {
//****************************************************************************** //******************************************************************************
template <typename T1, typename T2> template <typename T1, typename T2>

View File

@ -4,6 +4,10 @@
#include "../platform.h" #include "../platform.h"
#include "../private/choose_namespace.h"
#include "../private/choose_tag_types.h"
#include "../private/choose_pair_types.h"
#if defined(ETL_NO_STL) #if defined(ETL_NO_STL)
#include "alternate/functional.h" #include "alternate/functional.h"
#else #else

View File

@ -34,6 +34,10 @@ SOFTWARE.
#include "../platform.h" #include "../platform.h"
#include "../private/choose_namespace.h"
#include "../private/choose_tag_types.h"
#include "../private/choose_pair_types.h"
#if defined(ETL_NO_STL) #if defined(ETL_NO_STL)
#include "alternate/iterator.h" #include "alternate/iterator.h"
#else #else

View File

@ -33,6 +33,10 @@ SOFTWARE.
#include "../platform.h" #include "../platform.h"
#include "../private/choose_namespace.h"
#include "../private/choose_tag_types.h"
#include "../private/choose_pair_types.h"
#if defined(ETL_NO_STL) #if defined(ETL_NO_STL)
#include "alternate/limits.h" #include "alternate/limits.h"
#else #else

View File

@ -33,6 +33,10 @@ SOFTWARE.
#include "../platform.h" #include "../platform.h"
#include "../private/choose_namespace.h"
#include "../private/choose_tag_types.h"
#include "../private/choose_pair_types.h"
#if defined(ETL_NO_STL) #if defined(ETL_NO_STL)
#include "alternate/utility.h" #include "alternate/utility.h"
#else #else

View File

@ -109,7 +109,7 @@ namespace etl
typedef const T& const_reference; typedef const T& const_reference;
typedef const T* const_pointer; typedef const T* const_pointer;
typedef const T* const_iterator; typedef const T* const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
enum enum
{ {
@ -313,7 +313,7 @@ namespace etl
void assign(TIterator begin_, TIterator end_) void assign(TIterator begin_, TIterator end_)
{ {
mbegin = etl::addressof(*begin_); mbegin = etl::addressof(*begin_);
mend = etl::addressof(*begin_) + std::distance(begin_, end_); mend = etl::addressof(*begin_) + ETL_STD::distance(begin_, end_);
} }
//************************************************************************* //*************************************************************************
@ -351,8 +351,8 @@ namespace etl
//************************************************************************* //*************************************************************************
void swap(basic_string_view& other) void swap(basic_string_view& other)
{ {
std::swap(mbegin, other.mbegin); ETL_STD::swap(mbegin, other.mbegin);
std::swap(mend, other.mend); ETL_STD::swap(mend, other.mend);
} }
//************************************************************************* //*************************************************************************
@ -364,9 +364,9 @@ namespace etl
if (position < size()) if (position < size())
{ {
n = std::min(count, size() - position); n = ETL_STD::min(count, size() - position);
std::copy(mbegin + position, mbegin + position + n, destination); ETL_STD::copy(mbegin + position, mbegin + position + n, destination);
} }
return n; return n;
@ -381,7 +381,7 @@ namespace etl
if (position < size()) if (position < size())
{ {
size_t n = std::min(count, size() - position); size_t n = ETL_STD::min(count, size() - position);
view = basic_string_view(mbegin + position, mbegin + position + n); view = basic_string_view(mbegin + position, mbegin + position + n);
} }
@ -495,7 +495,7 @@ namespace etl
return npos; return npos;
} }
const_iterator iposition = std::search(begin() + position, end(), view.begin(), view.end()); const_iterator iposition = ETL_STD::search(begin() + position, end(), view.begin(), view.end());
if (iposition == end()) if (iposition == end())
{ {
@ -503,7 +503,7 @@ namespace etl
} }
else else
{ {
return std::distance(begin(), iposition); return ETL_STD::distance(begin(), iposition);
} }
} }
@ -532,12 +532,12 @@ namespace etl
return npos; return npos;
} }
position = std::min(position, size()); position = ETL_STD::min(position, size());
const_iterator iposition = std::find_end(begin(), const_iterator iposition = ETL_STD::find_end(begin(),
begin() + position, begin() + position,
view.begin(), view.begin(),
view.end()); view.end());
if (iposition == end()) if (iposition == end())
{ {
@ -545,7 +545,7 @@ namespace etl
} }
else else
{ {
return std::distance(begin(), iposition); return ETL_STD::distance(begin(), iposition);
} }
} }
@ -615,7 +615,7 @@ namespace etl
return npos; return npos;
} }
position = std::min(position, size() - 1); position = ETL_STD::min(position, size() - 1);
const_reverse_iterator it = rbegin() + size() - position - 1; const_reverse_iterator it = rbegin() + size() - position - 1;
@ -711,7 +711,7 @@ namespace etl
return npos; return npos;
} }
position = std::min(position, size() - 1); position = ETL_STD::min(position, size() - 1);
const_reverse_iterator it = rbegin() + size() - position - 1; const_reverse_iterator it = rbegin() + size() - position - 1;
@ -762,7 +762,7 @@ namespace etl
friend bool operator == (const etl::basic_string_view<T, TTraits>& lhs, const etl::basic_string_view<T, TTraits>& rhs) friend bool operator == (const etl::basic_string_view<T, TTraits>& lhs, const etl::basic_string_view<T, TTraits>& rhs)
{ {
return (lhs.size() == rhs.size()) && return (lhs.size() == rhs.size()) &&
std::equal(lhs.begin(), lhs.end(), rhs.begin()); ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//************************************************************************* //*************************************************************************
@ -778,7 +778,7 @@ namespace etl
//************************************************************************* //*************************************************************************
friend bool operator < (const etl::basic_string_view<T, TTraits>& lhs, const etl::basic_string_view<T, TTraits>& rhs) friend bool operator < (const etl::basic_string_view<T, TTraits>& lhs, const etl::basic_string_view<T, TTraits>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
} }
//************************************************************************* //*************************************************************************

View File

@ -180,7 +180,7 @@ namespace etl
{ {
ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds));
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
new_string.assign(buffer + position, buffer + position + length_); new_string.assign(buffer + position, buffer + position + length_);
} }

View File

@ -180,7 +180,7 @@ namespace etl
{ {
ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds));
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
new_string.assign(buffer + position, buffer + position + length_); new_string.assign(buffer + position, buffer + position + length_);
} }

View File

@ -54,6 +54,7 @@ SOFTWARE.
#include "error_handler.h" #include "error_handler.h"
#include "exception.h" #include "exception.h"
#include "debug_count.h" #include "debug_count.h"
#include "iterator.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "16" #define ETL_FILE "16"
@ -126,12 +127,12 @@ namespace etl
/// Can be used as a reference type for all unordered_map containing a specific type. /// Can be used as a reference type for all unordered_map containing a specific type.
///\ingroup unordered_map ///\ingroup unordered_map
//*************************************************************************** //***************************************************************************
template <typename TKey, typename T, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey> > template <typename TKey, typename T, typename THash = etl::hash<TKey>, typename TKeyEqual = ETL_STD::equal_to<TKey> >
class iunordered_map class iunordered_map
{ {
public: public:
typedef std::pair<const TKey, T> value_type; typedef ETL_PAIR<const TKey, T> value_type;
typedef TKey key_type; typedef TKey key_type;
typedef T mapped_type; typedef T mapped_type;
@ -171,7 +172,7 @@ namespace etl
typedef typename bucket_t::const_iterator local_const_iterator; typedef typename bucket_t::const_iterator local_const_iterator;
//********************************************************************* //*********************************************************************
class iterator : public std::iterator<std::forward_iterator_tag, T> class iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, T>
{ {
public: public:
@ -331,7 +332,7 @@ namespace etl
}; };
//********************************************************************* //*********************************************************************
class const_iterator : public std::iterator<std::forward_iterator_tag, const T> class const_iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, const T>
{ {
public: public:
@ -481,7 +482,7 @@ namespace etl
local_iterator inode; local_iterator inode;
}; };
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//********************************************************************* //*********************************************************************
/// Returns an iterator to the beginning of the unordered_map. /// Returns an iterator to the beginning of the unordered_map.
@ -608,7 +609,7 @@ namespace etl
{ {
size_t index = bucket(key); size_t index = bucket(key);
return std::distance(pbuckets[index].begin(), pbuckets[index].end()); return ETL_STD::distance(pbuckets[index].begin(), pbuckets[index].end());
} }
//********************************************************************* //*********************************************************************
@ -751,7 +752,7 @@ namespace etl
void assign(TIterator first_, TIterator last_) void assign(TIterator first_, TIterator last_)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first_, last_); difference_type d = ETL_STD::distance(first_, last_);
ETL_ASSERT(d >= 0, ETL_ERROR(unordered_map_iterator)); ETL_ASSERT(d >= 0, ETL_ERROR(unordered_map_iterator));
ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_map_full)); ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_map_full));
#endif #endif
@ -769,9 +770,9 @@ namespace etl
/// If asserts or exceptions are enabled, emits unordered_map_full if the unordered_map is already full. /// If asserts or exceptions are enabled, emits unordered_map_full if the unordered_map is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(const value_type& key_value_pair) ETL_PAIR<iterator, bool> insert(const value_type& key_value_pair)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
ETL_ASSERT(!full(), ETL_ERROR(unordered_map_full)); ETL_ASSERT(!full(), ETL_ERROR(unordered_map_full));
@ -1081,7 +1082,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair to the range of elements if the key exists, otherwise end(). ///\return An iterator pair to the range of elements if the key exists, otherwise end().
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
iterator f = find(key); iterator f = find(key);
iterator l = f; iterator l = f;
@ -1091,7 +1092,7 @@ namespace etl
++l; ++l;
} }
return std::pair<iterator, iterator>(f, l); return ETL_PAIR<iterator, iterator>(f, l);
} }
//********************************************************************* //*********************************************************************
@ -1102,7 +1103,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return A const iterator pair to the range of elements if the key exists, otherwise end(). ///\return A const iterator pair to the range of elements if the key exists, otherwise end().
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
const_iterator f = find(key); const_iterator f = find(key);
const_iterator l = f; const_iterator l = f;
@ -1112,7 +1113,7 @@ namespace etl
++l; ++l;
} }
return std::pair<const_iterator, const_iterator>(f, l); return ETL_PAIR<const_iterator, const_iterator>(f, l);
} }
//************************************************************************* //*************************************************************************
@ -1369,7 +1370,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::iunordered_map<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_map<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::iunordered_map<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_map<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -1388,7 +1389,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// A templated unordered_map implementation that uses a fixed size buffer. /// A templated unordered_map implementation that uses a fixed size buffer.
//************************************************************************* //*************************************************************************
template <typename TKey, typename TValue, const size_t MAX_SIZE_, const size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey> > template <typename TKey, typename TValue, const size_t MAX_SIZE_, const size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = ETL_STD::equal_to<TKey> >
class unordered_map : public etl::iunordered_map<TKey, TValue, THash, TKeyEqual> class unordered_map : public etl::iunordered_map<TKey, TValue, THash, TKeyEqual>
{ {
private: private:

View File

@ -54,6 +54,7 @@ SOFTWARE.
#include "error_handler.h" #include "error_handler.h"
#include "exception.h" #include "exception.h"
#include "debug_count.h" #include "debug_count.h"
#include "iterator.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "25" #define ETL_FILE "25"
@ -126,12 +127,12 @@ namespace etl
/// Can be used as a reference type for all unordered_multimap containing a specific type. /// Can be used as a reference type for all unordered_multimap containing a specific type.
///\ingroup unordered_multimap ///\ingroup unordered_multimap
//*************************************************************************** //***************************************************************************
template <typename TKey, typename T, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey> > template <typename TKey, typename T, typename THash = etl::hash<TKey>, typename TKeyEqual = ETL_STD::equal_to<TKey> >
class iunordered_multimap class iunordered_multimap
{ {
public: public:
typedef std::pair<const TKey, T> value_type; typedef ETL_PAIR<const TKey, T> value_type;
typedef TKey key_type; typedef TKey key_type;
typedef T mapped_type; typedef T mapped_type;
@ -170,7 +171,7 @@ namespace etl
typedef typename bucket_t::const_iterator local_const_iterator; typedef typename bucket_t::const_iterator local_const_iterator;
//********************************************************************* //*********************************************************************
class iterator : public std::iterator<std::forward_iterator_tag, T> class iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, T>
{ {
public: public:
@ -330,7 +331,7 @@ namespace etl
}; };
//********************************************************************* //*********************************************************************
class const_iterator : public std::iterator<std::forward_iterator_tag, const T> class const_iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, const T>
{ {
public: public:
@ -481,7 +482,7 @@ namespace etl
local_iterator inode; local_iterator inode;
}; };
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//********************************************************************* //*********************************************************************
/// Returns an iterator to the beginning of the unordered_multimap. /// Returns an iterator to the beginning of the unordered_multimap.
@ -608,7 +609,7 @@ namespace etl
{ {
size_t index = bucket(key); size_t index = bucket(key);
return std::distance(pbuckets[index].begin(), pbuckets[index].end()); return ETL_STD::distance(pbuckets[index].begin(), pbuckets[index].end());
} }
//********************************************************************* //*********************************************************************
@ -640,7 +641,7 @@ namespace etl
void assign(TIterator first_, TIterator last_) void assign(TIterator first_, TIterator last_)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first_, last_); difference_type d = ETL_STD::distance(first_, last_);
ETL_ASSERT(d >= 0, ETL_ERROR(unordered_multimap_iterator)); ETL_ASSERT(d >= 0, ETL_ERROR(unordered_multimap_iterator));
ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_multimap_full)); ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_multimap_full));
#endif #endif
@ -981,7 +982,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair to the range of elements if the key exists, otherwise end(). ///\return An iterator pair to the range of elements if the key exists, otherwise end().
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
iterator f = find(key); iterator f = find(key);
iterator l = f; iterator l = f;
@ -996,7 +997,7 @@ namespace etl
} }
} }
return std::pair<iterator, iterator>(f, l); return ETL_PAIR<iterator, iterator>(f, l);
} }
//********************************************************************* //*********************************************************************
@ -1007,7 +1008,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return A const iterator pair to the range of elements if the key exists, otherwise end(). ///\return A const iterator pair to the range of elements if the key exists, otherwise end().
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
const_iterator f = find(key); const_iterator f = find(key);
const_iterator l = f; const_iterator l = f;
@ -1022,7 +1023,7 @@ namespace etl
} }
} }
return std::pair<const_iterator, const_iterator>(f, l); return ETL_PAIR<const_iterator, const_iterator>(f, l);
} }
//************************************************************************* //*************************************************************************
@ -1278,7 +1279,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::iunordered_multimap<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_multimap<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::iunordered_multimap<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_multimap<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -1297,7 +1298,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// A templated unordered_multimap implementation that uses a fixed size buffer. /// A templated unordered_multimap implementation that uses a fixed size buffer.
//************************************************************************* //*************************************************************************
template <typename TKey, typename TValue, const size_t MAX_SIZE_, const size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey> > template <typename TKey, typename TValue, const size_t MAX_SIZE_, const size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = ETL_STD::equal_to<TKey> >
class unordered_multimap : public etl::iunordered_multimap<TKey, TValue, THash, TKeyEqual> class unordered_multimap : public etl::iunordered_multimap<TKey, TValue, THash, TKeyEqual>
{ {
private: private:

View File

@ -53,6 +53,7 @@ SOFTWARE.
#include "error_handler.h" #include "error_handler.h"
#include "exception.h" #include "exception.h"
#include "debug_count.h" #include "debug_count.h"
#include "iterator.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "26" #define ETL_FILE "26"
@ -125,7 +126,7 @@ namespace etl
/// Can be used as a reference type for all unordered_multiset containing a specific type. /// Can be used as a reference type for all unordered_multiset containing a specific type.
///\ingroup unordered_multiset ///\ingroup unordered_multiset
//*************************************************************************** //***************************************************************************
template <typename TKey, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey> > template <typename TKey, typename THash = etl::hash<TKey>, typename TKeyEqual = ETL_STD::equal_to<TKey> >
class iunordered_multiset class iunordered_multiset
{ {
public: public:
@ -167,7 +168,7 @@ namespace etl
typedef typename bucket_t::const_iterator local_const_iterator; typedef typename bucket_t::const_iterator local_const_iterator;
//********************************************************************* //*********************************************************************
class iterator : public std::iterator<std::forward_iterator_tag, TKey> class iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, TKey>
{ {
public: public:
@ -326,7 +327,7 @@ namespace etl
}; };
//********************************************************************* //*********************************************************************
class const_iterator : public std::iterator<std::forward_iterator_tag, const TKey> class const_iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, const TKey>
{ {
public: public:
@ -476,7 +477,7 @@ namespace etl
local_iterator inode; local_iterator inode;
}; };
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//********************************************************************* //*********************************************************************
/// Returns an iterator to the beginning of the unordered_multiset. /// Returns an iterator to the beginning of the unordered_multiset.
@ -603,7 +604,7 @@ namespace etl
{ {
size_t index = bucket(key); size_t index = bucket(key);
return std::distance(pbuckets[index].begin(), pbuckets[index].end()); return ETL_STD::distance(pbuckets[index].begin(), pbuckets[index].end());
} }
//********************************************************************* //*********************************************************************
@ -635,7 +636,7 @@ namespace etl
void assign(TIterator first_, TIterator last_) void assign(TIterator first_, TIterator last_)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first_, last_); difference_type d = ETL_STD::distance(first_, last_);
ETL_ASSERT(d >= 0, ETL_ERROR(unordered_multiset_iterator)); ETL_ASSERT(d >= 0, ETL_ERROR(unordered_multiset_iterator));
ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_multiset_full)); ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_multiset_full));
#endif #endif
@ -653,9 +654,9 @@ namespace etl
/// If asserts or exceptions are enabled, emits unordered_multiset_full if the unordered_multiset is already full. /// If asserts or exceptions are enabled, emits unordered_multiset_full if the unordered_multiset is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(const value_type& key) ETL_PAIR<iterator, bool> insert(const value_type& key)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
ETL_ASSERT(!full(), ETL_ERROR(unordered_multiset_full)); ETL_ASSERT(!full(), ETL_ERROR(unordered_multiset_full));
@ -976,7 +977,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair to the range of elements if the key exists, otherwise end(). ///\return An iterator pair to the range of elements if the key exists, otherwise end().
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
iterator f = find(key); iterator f = find(key);
iterator l = f; iterator l = f;
@ -991,7 +992,7 @@ namespace etl
} }
} }
return std::pair<iterator, iterator>(f, l); return ETL_PAIR<iterator, iterator>(f, l);
} }
//********************************************************************* //*********************************************************************
@ -1002,7 +1003,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return A const iterator pair to the range of elements if the key exists, otherwise end(). ///\return A const iterator pair to the range of elements if the key exists, otherwise end().
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
const_iterator f = find(key); const_iterator f = find(key);
const_iterator l = f; const_iterator l = f;
@ -1017,7 +1018,7 @@ namespace etl
} }
} }
return std::pair<const_iterator, const_iterator>(f, l); return ETL_PAIR<const_iterator, const_iterator>(f, l);
} }
//************************************************************************* //*************************************************************************
@ -1273,7 +1274,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::iunordered_multiset<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_multiset<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::iunordered_multiset<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_multiset<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -1292,7 +1293,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// A templated unordered_multiset implementation that uses a fixed size buffer. /// A templated unordered_multiset implementation that uses a fixed size buffer.
//************************************************************************* //*************************************************************************
template <typename TKey, const size_t MAX_SIZE_, size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey> > template <typename TKey, const size_t MAX_SIZE_, size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = ETL_STD::equal_to<TKey> >
class unordered_multiset : public etl::iunordered_multiset<TKey, THash, TKeyEqual> class unordered_multiset : public etl::iunordered_multiset<TKey, THash, TKeyEqual>
{ {
private: private:

View File

@ -54,6 +54,7 @@ SOFTWARE.
#include "exception.h" #include "exception.h"
#include "error_handler.h" #include "error_handler.h"
#include "debug_count.h" #include "debug_count.h"
#include "iterator.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "23" #define ETL_FILE "23"
@ -126,7 +127,7 @@ namespace etl
/// Can be used as a reference type for all unordered_set containing a specific type. /// Can be used as a reference type for all unordered_set containing a specific type.
///\ingroup unordered_set ///\ingroup unordered_set
//*************************************************************************** //***************************************************************************
template <typename TKey, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey> > template <typename TKey, typename THash = etl::hash<TKey>, typename TKeyEqual = ETL_STD::equal_to<TKey> >
class iunordered_set class iunordered_set
{ {
public: public:
@ -168,7 +169,7 @@ namespace etl
typedef typename bucket_t::const_iterator local_const_iterator; typedef typename bucket_t::const_iterator local_const_iterator;
//********************************************************************* //*********************************************************************
class iterator : public std::iterator<std::forward_iterator_tag, TKey> class iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, TKey>
{ {
public: public:
@ -327,7 +328,7 @@ namespace etl
}; };
//********************************************************************* //*********************************************************************
class const_iterator : public std::iterator<std::forward_iterator_tag, const TKey> class const_iterator : public etl::iterator<ETL_FORWARD_ITERATOR_TAG, const TKey>
{ {
public: public:
@ -477,7 +478,7 @@ namespace etl
local_iterator inode; local_iterator inode;
}; };
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
//********************************************************************* //*********************************************************************
/// Returns an iterator to the beginning of the unordered_set. /// Returns an iterator to the beginning of the unordered_set.
@ -604,7 +605,7 @@ namespace etl
{ {
size_t index = bucket(key); size_t index = bucket(key);
return std::distance(pbuckets[index].begin(), pbuckets[index].end()); return ETL_STD::distance(pbuckets[index].begin(), pbuckets[index].end());
} }
//********************************************************************* //*********************************************************************
@ -636,7 +637,7 @@ namespace etl
void assign(TIterator first_, TIterator last_) void assign(TIterator first_, TIterator last_)
{ {
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first_, last_); difference_type d = ETL_STD::distance(first_, last_);
ETL_ASSERT(d >= 0, ETL_ERROR(unordered_set_iterator)); ETL_ASSERT(d >= 0, ETL_ERROR(unordered_set_iterator));
ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_set_full)); ETL_ASSERT(size_t(d) <= max_size(), ETL_ERROR(unordered_set_full));
#endif #endif
@ -654,9 +655,9 @@ namespace etl
/// If asserts or exceptions are enabled, emits unordered_set_full if the unordered_set is already full. /// If asserts or exceptions are enabled, emits unordered_set_full if the unordered_set is already full.
///\param value The value to insert. ///\param value The value to insert.
//********************************************************************* //*********************************************************************
std::pair<iterator, bool> insert(const value_type& key) ETL_PAIR<iterator, bool> insert(const value_type& key)
{ {
std::pair<iterator, bool> result(end(), false); ETL_PAIR<iterator, bool> result(end(), false);
ETL_ASSERT(!full(), ETL_ERROR(unordered_set_full)); ETL_ASSERT(!full(), ETL_ERROR(unordered_set_full));
@ -963,7 +964,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return An iterator pair to the range of elements if the key exists, otherwise end(). ///\return An iterator pair to the range of elements if the key exists, otherwise end().
//********************************************************************* //*********************************************************************
std::pair<iterator, iterator> equal_range(key_parameter_t key) ETL_PAIR<iterator, iterator> equal_range(key_parameter_t key)
{ {
iterator f = find(key); iterator f = find(key);
iterator l = f; iterator l = f;
@ -973,7 +974,7 @@ namespace etl
++l; ++l;
} }
return std::pair<iterator, iterator>(f, l); return ETL_PAIR<iterator, iterator>(f, l);
} }
//********************************************************************* //*********************************************************************
@ -984,7 +985,7 @@ namespace etl
///\param key The key to search for. ///\param key The key to search for.
///\return A const iterator pair to the range of elements if the key exists, otherwise end(). ///\return A const iterator pair to the range of elements if the key exists, otherwise end().
//********************************************************************* //*********************************************************************
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const ETL_PAIR<const_iterator, const_iterator> equal_range(key_parameter_t key) const
{ {
const_iterator f = find(key); const_iterator f = find(key);
const_iterator l = f; const_iterator l = f;
@ -994,7 +995,7 @@ namespace etl
++l; ++l;
} }
return std::pair<const_iterator, const_iterator>(f, l); return ETL_PAIR<const_iterator, const_iterator>(f, l);
} }
//************************************************************************* //*************************************************************************
@ -1250,7 +1251,7 @@ namespace etl
template <typename TKey, typename TMapped, typename TKeyCompare> template <typename TKey, typename TMapped, typename TKeyCompare>
bool operator ==(const etl::iunordered_set<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_set<TKey, TMapped, TKeyCompare>& rhs) bool operator ==(const etl::iunordered_set<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_set<TKey, TMapped, TKeyCompare>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -1269,7 +1270,7 @@ namespace etl
//************************************************************************* //*************************************************************************
/// A templated unordered_set implementation that uses a fixed size buffer. /// A templated unordered_set implementation that uses a fixed size buffer.
//************************************************************************* //*************************************************************************
template <typename TKey, const size_t MAX_SIZE_, size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey> > template <typename TKey, const size_t MAX_SIZE_, size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = ETL_STD::equal_to<TKey> >
class unordered_set : public etl::iunordered_set<TKey, THash, TKeyEqual> class unordered_set : public etl::iunordered_set<TKey, THash, TKeyEqual>
{ {
private: private:

View File

@ -723,7 +723,7 @@ namespace etl
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type"); ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
destruct_current(); destruct_current();
::new (static_cast<T*>(data)) T(std::forward<Args>(args)...); ::new (static_cast<T*>(data)) T(ETL_STD::forward<Args>(args)...);
type_id = Type_Id_Lookup<T>::type_id; type_id = Type_Id_Lookup<T>::type_id;
return *static_cast<T*>(data); return *static_cast<T*>(data);

View File

@ -31,7 +31,7 @@ SOFTWARE.
#endif #endif
//*************************************************************************** //***************************************************************************
// This file has been auto generated. Do not edit this file. // THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
//*************************************************************************** //***************************************************************************
//*************************************************************************** //***************************************************************************
@ -54,9 +54,6 @@ SOFTWARE.
#include <stdint.h> #include <stdint.h>
#include "platform.h" #include "platform.h"
#include "stl/utility.h"
#include "error_handler.h" #include "error_handler.h"
#include "exception.h" #include "exception.h"
#include "largest.h" #include "largest.h"
@ -66,6 +63,8 @@ SOFTWARE.
#include "type_lookup.h" #include "type_lookup.h"
#include "pool.h" #include "pool.h"
#include "stl/utility.h"
#undef ETL_FILE #undef ETL_FILE
#define ETL_FILE "40" #define ETL_FILE "40"
@ -135,7 +134,7 @@ namespace etl
{ {
} }
#if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT) || defined(ETL_NO_STL) #if !ETL_CPP11_SUPPORTED || defined(ETL_STLPORT)
//************************************************************************* //*************************************************************************
/// Creates the object. Default constructor. /// Creates the object. Default constructor.
//************************************************************************* //*************************************************************************
@ -291,7 +290,7 @@ namespace etl
if (p != nullptr) if (p != nullptr)
{ {
new (p) T(std::forward<Args>(args)...); new (p) T(ETL_STD::forward<Args>(args)...);
} }
} }

View File

@ -357,7 +357,7 @@ namespace etl
if (p != nullptr) if (p != nullptr)
{ {
new (p) T(std::forward<Args>(args)...); new (p) T(ETL_STD::forward<Args>(args)...);
} }
} }

View File

@ -92,10 +92,10 @@ namespace etl
typedef const T* const_pointer; typedef const T* const_pointer;
typedef T* iterator; typedef T* iterator;
typedef const T* const_iterator; typedef const T* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef ETL_STD::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef ETL_STD::reverse_iterator<const_iterator> const_reverse_iterator;
typedef size_t size_type; typedef size_t size_type;
typedef typename std::iterator_traits<iterator>::difference_type difference_type; typedef typename ETL_STD::iterator_traits<iterator>::difference_type difference_type;
protected: protected:
@ -365,17 +365,17 @@ namespace etl
template <typename TIterator> template <typename TIterator>
void assign(TIterator first, TIterator last) void assign(TIterator first, TIterator last)
{ {
ETL_STATIC_ASSERT((etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename std::iterator_traits<TIterator>::value_type>::type>::value), "Iterator type does not match container type"); ETL_STATIC_ASSERT((etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename ETL_STD::iterator_traits<TIterator>::value_type>::type>::value), "Iterator type does not match container type");
#if defined(ETL_DEBUG) #if defined(ETL_DEBUG)
difference_type d = std::distance(first, last); difference_type d = ETL_STD::distance(first, last);
ETL_ASSERT(static_cast<size_t>(d) <= CAPACITY, ETL_ERROR(vector_full)); ETL_ASSERT(static_cast<size_t>(d) <= CAPACITY, ETL_ERROR(vector_full));
#endif #endif
initialise(); initialise();
p_end = etl::uninitialized_copy(first, last, p_buffer); p_end = etl::uninitialized_copy(first, last, p_buffer);
ETL_ADD_DEBUG_COUNT(uint32_t(std::distance(first, last))) ETL_ADD_DEBUG_COUNT(uint32_t(ETL_STD::distance(first, last)))
} }
//********************************************************************* //*********************************************************************
@ -426,7 +426,7 @@ namespace etl
#if defined(ETL_CHECK_PUSH_POP) #if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
#endif #endif
create_back(std::move(value)); create_back(ETL_STD::move(value));
} }
#endif #endif
@ -442,7 +442,7 @@ namespace etl
#if defined(ETL_CHECK_PUSH_POP) #if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full)); ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
#endif #endif
::new (p_end) T(std::forward<Args>(args)...); ::new (p_end) T(ETL_STD::forward<Args>(args)...);
++p_end; ++p_end;
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
} }
@ -541,7 +541,7 @@ namespace etl
else else
{ {
create_back(back()); create_back(back());
std::copy_backward(position, p_end - 2, p_end - 1); ETL_STD::copy_backward(position, p_end - 2, p_end - 1);
*position = value; *position = value;
} }
@ -561,13 +561,13 @@ namespace etl
if (position == end()) if (position == end())
{ {
create_back(std::move(value)); create_back(ETL_STD::move(value));
} }
else else
{ {
create_back(std::move(back())); create_back(ETL_STD::move(back()));
std::move_backward(position, p_end - 2, p_end - 1); ETL_STD::move_backward(position, p_end - 2, p_end - 1);
*position = std::move(value); *position = ETL_STD::move(value);
} }
return position; return position;
@ -594,11 +594,11 @@ namespace etl
{ {
p = etl::addressof(*position); p = etl::addressof(*position);
create_back(back()); create_back(back());
std::copy_backward(position, p_end - 2, p_end - 1); ETL_STD::copy_backward(position, p_end - 2, p_end - 1);
(*position).~T(); (*position).~T();
} }
::new (p) T(std::forward<Args>(args)...); ::new (p) T(ETL_STD::forward<Args>(args)...);
return position; return position;
} }
@ -619,7 +619,7 @@ namespace etl
{ {
p = etl::addressof(*position); p = etl::addressof(*position);
create_back(back()); create_back(back());
std::copy_backward(position, p_end - 2, p_end - 1); ETL_STD::copy_backward(position, p_end - 2, p_end - 1);
(*position).~T(); (*position).~T();
} }
@ -644,7 +644,7 @@ namespace etl
{ {
p = etl::addressof(*position); p = etl::addressof(*position);
create_back(back()); create_back(back());
std::copy_backward(position, p_end - 2, p_end - 1); ETL_STD::copy_backward(position, p_end - 2, p_end - 1);
(*position).~T(); (*position).~T();
} }
@ -669,7 +669,7 @@ namespace etl
{ {
p = etl::addressof(*position); p = etl::addressof(*position);
create_back(back()); create_back(back());
std::copy_backward(position, p_end - 2, p_end - 1); ETL_STD::copy_backward(position, p_end - 2, p_end - 1);
(*position).~T(); (*position).~T();
} }
@ -694,7 +694,7 @@ namespace etl
{ {
p = etl::addressof(*position); p = etl::addressof(*position);
create_back(back()); create_back(back());
std::copy_backward(position, p_end - 2, p_end - 1); ETL_STD::copy_backward(position, p_end - 2, p_end - 1);
(*position).~T(); (*position).~T();
} }
@ -716,7 +716,7 @@ namespace etl
ETL_ASSERT((size() + n) <= CAPACITY, ETL_ERROR(vector_full)); ETL_ASSERT((size() + n) <= CAPACITY, ETL_ERROR(vector_full));
size_t insert_n = n; size_t insert_n = n;
size_t insert_begin = std::distance(begin(), position); size_t insert_begin = ETL_STD::distance(begin(), position);
size_t insert_end = insert_begin + insert_n; size_t insert_end = insert_begin + insert_n;
// Copy old data. // Copy old data.
@ -745,14 +745,14 @@ namespace etl
ETL_ADD_DEBUG_COUNT(construct_old_n) ETL_ADD_DEBUG_COUNT(construct_old_n)
// Copy old. // Copy old.
std::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n); ETL_STD::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n);
// Construct new. // Construct new.
etl::uninitialized_fill_n(p_end, construct_new_n, value); etl::uninitialized_fill_n(p_end, construct_new_n, value);
ETL_ADD_DEBUG_COUNT(construct_new_n) ETL_ADD_DEBUG_COUNT(construct_new_n)
// Copy new. // Copy new.
std::fill_n(p_buffer + insert_begin, copy_new_n, value); ETL_STD::fill_n(p_buffer + insert_begin, copy_new_n, value);
p_end += n; p_end += n;
} }
@ -768,12 +768,12 @@ namespace etl
template <class TIterator> template <class TIterator>
void insert(iterator position, TIterator first, TIterator last) void insert(iterator position, TIterator first, TIterator last)
{ {
size_t count = std::distance(first, last); size_t count = ETL_STD::distance(first, last);
ETL_ASSERT((size() + count) <= CAPACITY, ETL_ERROR(vector_full)); ETL_ASSERT((size() + count) <= CAPACITY, ETL_ERROR(vector_full));
size_t insert_n = count; size_t insert_n = count;
size_t insert_begin = std::distance(begin(), position); size_t insert_begin = ETL_STD::distance(begin(), position);
size_t insert_end = insert_begin + insert_n; size_t insert_end = insert_begin + insert_n;
// Copy old data. // Copy old data.
@ -802,7 +802,7 @@ namespace etl
ETL_ADD_DEBUG_COUNT(construct_old_n) ETL_ADD_DEBUG_COUNT(construct_old_n)
// Copy old. // Copy old.
std::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n); ETL_STD::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n);
// Construct new. // Construct new.
etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end); etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end);
@ -821,7 +821,7 @@ namespace etl
//********************************************************************* //*********************************************************************
iterator erase(iterator i_element) iterator erase(iterator i_element)
{ {
std::copy(i_element + 1, end(), i_element); ETL_STD::copy(i_element + 1, end(), i_element);
destroy_back(); destroy_back();
return i_element; return i_element;
@ -843,8 +843,8 @@ namespace etl
} }
else else
{ {
std::copy(last, end(), first); ETL_STD::copy(last, end(), first);
size_t n_delete = std::distance(first, last); size_t n_delete = ETL_STD::distance(first, last);
// Destroy the elements left over at the end. // Destroy the elements left over at the end.
etl::destroy(p_end - n_delete, p_end); etl::destroy(p_end - n_delete, p_end);
@ -880,7 +880,7 @@ namespace etl
iterator itr = rhs.begin(); iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
push_back(std::move(*itr)); push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -952,7 +952,7 @@ namespace etl
void initialise() void initialise()
{ {
etl::destroy(p_buffer, p_end); etl::destroy(p_buffer, p_end);
ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) ETL_SUBTRACT_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end)))
p_end = p_buffer; p_end = p_buffer;
} }
@ -962,7 +962,7 @@ namespace etl
//********************************************************************* //*********************************************************************
void initialise_source_external_buffer_after_move() void initialise_source_external_buffer_after_move()
{ {
ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) ETL_SUBTRACT_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end)))
p_end = p_buffer; p_end = p_buffer;
} }
@ -972,7 +972,7 @@ namespace etl
//********************************************************************* //*********************************************************************
void initialise_destination_external_buffer_after_move() void initialise_destination_external_buffer_after_move()
{ {
ETL_ADD_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))) ETL_ADD_DEBUG_COUNT(int32_t(ETL_STD::distance(p_buffer, p_end)))
} }
//************************************************************************* //*************************************************************************
@ -1018,7 +1018,7 @@ namespace etl
//********************************************************************* //*********************************************************************
inline void create_back(rvalue_reference value) inline void create_back(rvalue_reference value)
{ {
etl::create_copy_at(p_end, std::move(value)); etl::create_copy_at(p_end, ETL_STD::move(value));
ETL_INCREMENT_DEBUG_COUNT ETL_INCREMENT_DEBUG_COUNT
++p_end; ++p_end;
@ -1065,7 +1065,7 @@ namespace etl
template <typename T> template <typename T>
bool operator ==(const etl::ivector<T>& lhs, const etl::ivector<T>& rhs) bool operator ==(const etl::ivector<T>& lhs, const etl::ivector<T>& rhs)
{ {
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin()); return (lhs.size() == rhs.size()) && ETL_STD::equal(lhs.begin(), lhs.end(), rhs.begin());
} }
//*************************************************************************** //***************************************************************************
@ -1091,7 +1091,7 @@ namespace etl
template <typename T> template <typename T>
bool operator <(const etl::ivector<T>& lhs, const etl::ivector<T>& rhs) bool operator <(const etl::ivector<T>& lhs, const etl::ivector<T>& rhs)
{ {
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); return ETL_STD::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
} }
//*************************************************************************** //***************************************************************************
@ -1243,7 +1243,7 @@ namespace etl
typename etl::ivector<T>::iterator itr = other.begin(); typename etl::ivector<T>::iterator itr = other.begin();
while (itr != other.end()) while (itr != other.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -1262,7 +1262,7 @@ namespace etl
typename etl::ivector<T>::iterator itr = rhs.begin(); typename etl::ivector<T>::iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -1290,7 +1290,7 @@ namespace etl
void repair() void repair()
{ {
#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
ETL_ASSERT(std::is_trivially_copyable<T>::value, ETL_ERROR(etl::vector_incompatible_type)); ETL_ASSERT(etl::is_trivially_copyable<T>::value, ETL_ERROR(etl::vector_incompatible_type));
#endif #endif
etl::ivector<T>::repair_buffer(buffer); etl::ivector<T>::repair_buffer(buffer);
@ -1445,7 +1445,7 @@ namespace etl
void repair() void repair()
{ {
#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
ETL_ASSERT(std::is_trivially_copyable<T>::value, ETL_ERROR(etl::vector_incompatible_type)); ETL_ASSERT(etl::is_trivially_copyable<T>::value, ETL_ERROR(etl::vector_incompatible_type));
#endif #endif
etl::ivector<T>::repair_buffer(this->p_buffer); etl::ivector<T>::repair_buffer(this->p_buffer);
@ -1560,7 +1560,7 @@ namespace etl
typename etl::ivector<T*>::iterator itr = other.begin(); typename etl::ivector<T*>::iterator itr = other.begin();
while (itr != other.end()) while (itr != other.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }
@ -1579,7 +1579,7 @@ namespace etl
typename etl::ivector<T*>::iterator itr = rhs.begin(); typename etl::ivector<T*>::iterator itr = rhs.begin();
while (itr != rhs.end()) while (itr != rhs.end())
{ {
this->push_back(std::move(*itr)); this->push_back(ETL_STD::move(*itr));
++itr; ++itr;
} }

View File

@ -37,9 +37,9 @@ SOFTWARE.
/// Definitions of the ETL version /// Definitions of the ETL version
///\ingroup utilities ///\ingroup utilities
#define ETL_VERSION_MAJOR 14 #define ETL_VERSION_MAJOR 15
#define ETL_VERSION_MINOR 38 #define ETL_VERSION_MINOR 0
#define ETL_VERSION_PATCH 2 #define ETL_VERSION_PATCH 0
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)

View File

@ -181,7 +181,7 @@ namespace etl
{ {
ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds)); ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds));
length_ = std::min(length_, size() - position); length_ = ETL_STD::min(length_, size() - position);
new_string.assign(buffer + position, buffer + position + length_); new_string.assign(buffer + position, buffer + position + length_);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Embedded Template Library", "name": "Embedded Template Library",
"version": "14.38.2", "version": "15.0.0",
"authors": { "authors": {
"name": "John Wellbelove", "name": "John Wellbelove",
"email": "<john.wellbelove@etlcpp.com>" "email": "<john.wellbelove@etlcpp.com>"

View File

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

View File

@ -1,3 +1,8 @@
===============================================================================
15.0.0
Unit tests and library code updated so that the ETL may be compiled and tested
with and without STL support.
=============================================================================== ===============================================================================
14.38.2 14.38.2
Added alternate 'No STL' reverse_iterator unit tests. Added alternate 'No STL' reverse_iterator unit tests.

View File

@ -25,6 +25,26 @@
<Add after="${TARGET_OUTPUT_DIR}${TARGET_OUTPUT_BASENAME}" /> <Add after="${TARGET_OUTPUT_DIR}${TARGET_OUTPUT_BASENAME}" />
</ExtraCommands> </ExtraCommands>
</Target> </Target>
<Target title="Windows No STL">
<Option output="bin/Debug No STL/ETL" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-std=c++17" />
<Add option="-m32" />
<Add option="-g" />
<Add option="-D_DEBUG" />
<Add option="-DETL_NO_STL" />
<Add directory="../../src" />
</Compiler>
<Linker>
<Add option="-m32" />
</Linker>
<ExtraCommands>
<Add after="${TARGET_OUTPUT_DIR}${TARGET_OUTPUT_BASENAME}" />
</ExtraCommands>
</Target>
<Target title="Linux"> <Target title="Linux">
<Option output="bin/Debug/ETL" prefix_auto="1" extension_auto="1" /> <Option output="bin/Debug/ETL" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" /> <Option object_output="obj/Debug/" />
@ -41,7 +61,7 @@
</ExtraCommands> </ExtraCommands>
</Target> </Target>
<Target title="Windows 64"> <Target title="Windows 64">
<Option output="bin/Debug/ETL" prefix_auto="1" extension_auto="1" /> <Option output="bin/Debug 64/ETL" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" /> <Option object_output="obj/Debug/" />
<Option type="1" /> <Option type="1" />
<Option compiler="gcc" /> <Option compiler="gcc" />
@ -141,6 +161,7 @@
<Unit filename="../../../unittest-cpp/UnitTest++/Win32/TimeHelpers.cpp"> <Unit filename="../../../unittest-cpp/UnitTest++/Win32/TimeHelpers.cpp">
<Option target="Windows" /> <Option target="Windows" />
<Option target="Windows 64" /> <Option target="Windows 64" />
<Option target="Windows No STL" />
</Unit> </Unit>
<Unit filename="../../../unittest-cpp/UnitTest++/Win32/TimeHelpers.h"> <Unit filename="../../../unittest-cpp/UnitTest++/Win32/TimeHelpers.h">
<Option target="&lt;{~None~}&gt;" /> <Option target="&lt;{~None~}&gt;" />

View File

@ -91,6 +91,10 @@ SOFTWARE.
//#define ETL_OPTIONAL_FORCE_CPP03 //#define ETL_OPTIONAL_FORCE_CPP03
//#define ETL_LARGEST_TYPE_FORCE_CPP03 //#define ETL_LARGEST_TYPE_FORCE_CPP03
#if defined(ETL_NO_STL)
#define ETL_TIMER_SEMAPHORE_TYPE uint32_t
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
#include "etl/profiles/msvc_x86.h" #include "etl/profiles/msvc_x86.h"
#else #else

View File

@ -31,10 +31,13 @@ SOFTWARE.
#ifndef ETL_NO_STL_TEST_ITERATORS_INCLUDED #ifndef ETL_NO_STL_TEST_ITERATORS_INCLUDED
#define ETL_NO_STL_TEST_ITERATORS_INCLUDED #define ETL_NO_STL_TEST_ITERATORS_INCLUDED
#include "etl/stl/alternate/iterator.h" #include "etl/platform.h"
#include "etl/iterator.h"
#include "etl/stl/iterator.h"
template <typename T> template <typename T>
struct non_random_iterator : public etlstd::iterator<etlstd::bidirectional_iterator_tag, T> struct non_random_iterator : public etl::iterator<ETL_BIDIRECTIONAL_ITERATOR_TAG, T>
{ {
non_random_iterator() non_random_iterator()
: ptr(nullptr) : ptr(nullptr)
@ -113,7 +116,7 @@ bool operator !=(const non_random_iterator<T>& lhs, const non_random_iterator<T>
} }
template <typename T> template <typename T>
struct random_iterator : public etlstd::iterator<etlstd::random_access_iterator_tag, T> struct random_iterator : public etl::iterator<ETL_RANDOM_ACCESS_ITERATOR_TAG, T>
{ {
random_iterator() random_iterator()
: ptr(nullptr) : ptr(nullptr)
@ -203,4 +206,4 @@ ptrdiff_t operator -(const random_iterator<T>& lhs, const random_iterator<T>& rh
return lhs.ptr - rhs.ptr; return lhs.ptr - rhs.ptr;
} }
#endif #endif

View File

@ -87,8 +87,8 @@ namespace
//========================================================================= //=========================================================================
TEST(minmax_element) TEST(minmax_element)
{ {
std::pair<Data::iterator, Data::iterator> expected = std::minmax_element(data.begin(), data.end()); ETL_PAIR<Data::iterator, Data::iterator> expected = std::minmax_element(data.begin(), data.end());
std::pair<Data::iterator, Data::iterator> result = etl::minmax_element(data.begin(), data.end()); ETL_PAIR<Data::iterator, Data::iterator> result = etl::minmax_element(data.begin(), data.end());
CHECK_EQUAL(std::distance(data.begin(), expected.first), std::distance(data.begin(), result.first)); CHECK_EQUAL(std::distance(data.begin(), expected.first), std::distance(data.begin(), result.first));
CHECK_EQUAL(std::distance(data.begin(), expected.second), std::distance(data.begin(), result.second)); CHECK_EQUAL(std::distance(data.begin(), expected.second), std::distance(data.begin(), result.second));
} }
@ -96,8 +96,8 @@ namespace
//========================================================================= //=========================================================================
TEST(minmax_element_compare) TEST(minmax_element_compare)
{ {
std::pair<Data::iterator, Data::iterator> expected = std::minmax_element(data.begin(), data.end(), std::greater<int>()); ETL_PAIR<Data::iterator, Data::iterator> expected = std::minmax_element(data.begin(), data.end(), std::greater<int>());
std::pair<Data::iterator, Data::iterator> result = etl::minmax_element(data.begin(), data.end(), std::greater<int>()); ETL_PAIR<Data::iterator, Data::iterator> result = etl::minmax_element(data.begin(), data.end(), std::greater<int>());
CHECK_EQUAL(std::distance(data.begin(), expected.first), std::distance(data.begin(), result.first)); CHECK_EQUAL(std::distance(data.begin(), expected.first), std::distance(data.begin(), result.first));
CHECK_EQUAL(std::distance(data.begin(), expected.second), std::distance(data.begin(), result.second)); CHECK_EQUAL(std::distance(data.begin(), expected.second), std::distance(data.begin(), result.second));
} }
@ -108,8 +108,8 @@ namespace
int a = 1; int a = 1;
int b = 2; int b = 2;
std::pair<int, int> expected = std::minmax(a, b); ETL_PAIR<int, int> expected = std::minmax(a, b);
std::pair<int, int> result = etl::minmax(a, b); ETL_PAIR<int, int> result = etl::minmax(a, b);
CHECK_EQUAL(expected.first, result.first); CHECK_EQUAL(expected.first, result.first);
CHECK_EQUAL(expected.second, result.second); CHECK_EQUAL(expected.second, result.second);
@ -125,8 +125,8 @@ namespace
int a = 1; int a = 1;
int b = 2; int b = 2;
std::pair<int, int> expected = std::minmax(a, b, std::greater<int>()); ETL_PAIR<int, int> expected = std::minmax(a, b, std::greater<int>());
std::pair<int, int> result = etl::minmax(a, b, std::greater<int>()); ETL_PAIR<int, int> result = etl::minmax(a, b, std::greater<int>());
CHECK_EQUAL(expected.first, result.first); CHECK_EQUAL(expected.first, result.first);
CHECK_EQUAL(expected.second, result.second); CHECK_EQUAL(expected.second, result.second);

View File

@ -136,6 +136,7 @@ namespace
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
} }
#if !defined(ETL_NO_STL)
//************************************************************************* //*************************************************************************
TEST(test_constructor_initializer_list) TEST(test_constructor_initializer_list)
{ {
@ -145,6 +146,7 @@ namespace
CHECK_EQUAL(compare_data.size(), data.size()); CHECK_EQUAL(compare_data.size(), data.size());
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
} }
#endif
//************************************************************************* //*************************************************************************
TEST(test_copy_constructor) TEST(test_copy_constructor)

View File

@ -49,10 +49,10 @@ namespace
typedef TestDataDC<std::string> DC; typedef TestDataDC<std::string> DC;
typedef TestDataNDC<std::string> NDC; typedef TestDataNDC<std::string> NDC;
typedef std::pair<int, DC> ElementDC; typedef ETL_PAIR<int, DC> ElementDC;
typedef std::pair<int, NDC> ElementNDC; typedef ETL_PAIR<int, NDC> ElementNDC;
typedef std::pair<int, int> ElementInt; typedef ETL_PAIR<int, int> ElementInt;
typedef etl::flat_map<int, DC, SIZE> DataDC; typedef etl::flat_map<int, DC, SIZE> DataDC;
typedef etl::flat_map<int, NDC, SIZE> DataNDC; typedef etl::flat_map<int, NDC, SIZE> DataNDC;
@ -156,10 +156,10 @@ namespace
return !(lhs == rhs); return !(lhs == rhs);
} }
typedef std::pair<const int, D1> Element1; typedef ETL_PAIR<const int, D1> Element1;
typedef std::pair<const int, D2> Element2; typedef ETL_PAIR<const int, D2> Element2;
typedef std::pair<const int, D3> Element3; typedef ETL_PAIR<const int, D3> Element3;
typedef std::pair<const int, D4> Element4; typedef ETL_PAIR<const int, D4> Element4;
typedef etl::flat_map<int, D1, SIZE> Data1; typedef etl::flat_map<int, D1, SIZE> Data1;
typedef etl::flat_map<int, D2, SIZE> Data2; typedef etl::flat_map<int, D2, SIZE> Data2;
@ -336,6 +336,7 @@ namespace
CHECK(!data.empty()); CHECK(!data.empty());
} }
#if !defined(ETL_NO_STL)
//************************************************************************* //*************************************************************************
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
{ {
@ -351,6 +352,7 @@ namespace
compare_data.begin()); compare_data.begin());
CHECK(isEqual); CHECK(isEqual);
} }
#endif
//************************************************************************* //*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment) TEST_FIXTURE(SetupFixture, test_assignment)
@ -590,10 +592,10 @@ namespace
Compare_DataNDC compare_data; Compare_DataNDC compare_data;
DataNDC data; DataNDC data;
std::pair<DataNDC::iterator, bool> result; ETL_PAIR<DataNDC::iterator, bool> result;
result = data.insert(std::make_pair(0, N0)); result = data.insert(ETL_MAKE_PAIR(0, N0));
compare_data.insert(std::make_pair(0, N0)); compare_data.insert(ETL_MAKE_PAIR(0, N0));
bool isEqual = Check_Equal(data.begin(), bool isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -603,8 +605,8 @@ namespace
CHECK(result.second); CHECK(result.second);
CHECK(*result.first == DataNDC::value_type(0, N0)); CHECK(*result.first == DataNDC::value_type(0, N0));
result = data.insert(std::make_pair(2, N2)); result = data.insert(ETL_MAKE_PAIR(2, N2));
compare_data.insert(std::make_pair(2, N2)); compare_data.insert(ETL_MAKE_PAIR(2, N2));
isEqual = Check_Equal(data.begin(), isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -614,8 +616,8 @@ namespace
CHECK(result.second); CHECK(result.second);
CHECK(*result.first == DataNDC::value_type(2, N2)); CHECK(*result.first == DataNDC::value_type(2, N2));
result = data.insert(std::make_pair(1, N1)); result = data.insert(ETL_MAKE_PAIR(1, N1));
compare_data.insert(std::make_pair(1, N1)); compare_data.insert(ETL_MAKE_PAIR(1, N1));
isEqual = Check_Equal(data.begin(), isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -634,11 +636,11 @@ namespace
Compare_DataNDC compare_data; Compare_DataNDC compare_data;
DataNDC data; DataNDC data;
std::pair<DataNDC::iterator, bool> result1; ETL_PAIR<DataNDC::iterator, bool> result1;
std::pair<Compare_DataNDC::iterator, bool> result2; ETL_PAIR<Compare_DataNDC::iterator, bool> result2;
result1 = data.insert(DataNDC::value_type(0, N0)); result1 = data.insert(DataNDC::value_type(0, N0));
result2 = compare_data.insert(std::make_pair(0, N0)); result2 = compare_data.insert(ETL_MAKE_PAIR(0, N0));
bool isEqual = Check_Equal(data.begin(), bool isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -648,8 +650,8 @@ namespace
CHECK(result1.second); CHECK(result1.second);
CHECK(*result1.first == DataNDC::value_type(0, N0)); CHECK(*result1.first == DataNDC::value_type(0, N0));
result1 = data.insert(std::make_pair(0, N2)); result1 = data.insert(ETL_MAKE_PAIR(0, N2));
result2 = compare_data.insert(std::make_pair(0, N2)); result2 = compare_data.insert(ETL_MAKE_PAIR(0, N2));
isEqual = Check_Equal(data.begin(), isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -666,37 +668,37 @@ namespace
Compare_DataNDC compare_data; Compare_DataNDC compare_data;
DataNDC data; DataNDC data;
std::pair<DataNDC::iterator, bool> dr; ETL_PAIR<DataNDC::iterator, bool> dr;
std::pair<Compare_DataNDC::iterator, bool> cr; ETL_PAIR<Compare_DataNDC::iterator, bool> cr;
dr = data.insert(std::make_pair(0, N0)); dr = data.insert(ETL_MAKE_PAIR(0, N0));
cr = compare_data.insert(std::make_pair(0, N0)); cr = compare_data.insert(ETL_MAKE_PAIR(0, N0));
CHECK(dr.first->first == cr.first->first); CHECK(dr.first->first == cr.first->first);
CHECK(dr.second == cr.second); CHECK(dr.second == cr.second);
dr = data.insert(std::make_pair(1, N1)); dr = data.insert(ETL_MAKE_PAIR(1, N1));
cr = compare_data.insert(std::make_pair(1, N1)); cr = compare_data.insert(ETL_MAKE_PAIR(1, N1));
CHECK(dr.first->first == cr.first->first); CHECK(dr.first->first == cr.first->first);
CHECK(dr.second == cr.second); CHECK(dr.second == cr.second);
dr = data.insert(std::make_pair(2, N2)); dr = data.insert(ETL_MAKE_PAIR(2, N2));
cr = compare_data.insert(std::make_pair(2, N2)); cr = compare_data.insert(ETL_MAKE_PAIR(2, N2));
CHECK(dr.first->first == cr.first->first); CHECK(dr.first->first == cr.first->first);
CHECK(dr.second == cr.second); CHECK(dr.second == cr.second);
// Do it again. // Do it again.
dr = data.insert(std::make_pair(0, N0)); dr = data.insert(ETL_MAKE_PAIR(0, N0));
cr = compare_data.insert(std::make_pair(0, N0)); cr = compare_data.insert(ETL_MAKE_PAIR(0, N0));
CHECK(dr.first->first == cr.first->first); CHECK(dr.first->first == cr.first->first);
CHECK(dr.second == cr.second); CHECK(dr.second == cr.second);
dr = data.insert(std::make_pair(1, N1)); dr = data.insert(ETL_MAKE_PAIR(1, N1));
cr = compare_data.insert(std::make_pair(1, N1)); cr = compare_data.insert(ETL_MAKE_PAIR(1, N1));
CHECK(dr.first->first == cr.first->first); CHECK(dr.first->first == cr.first->first);
CHECK(dr.second == cr.second); CHECK(dr.second == cr.second);
dr = data.insert(std::make_pair(2, N2)); dr = data.insert(ETL_MAKE_PAIR(2, N2));
cr = compare_data.insert(std::make_pair(2, N2)); cr = compare_data.insert(ETL_MAKE_PAIR(2, N2));
CHECK(dr.first->first == cr.first->first); CHECK(dr.first->first == cr.first->first);
CHECK(dr.second == cr.second); CHECK(dr.second == cr.second);
@ -714,7 +716,7 @@ namespace
{ {
DataNDC data(initial_data.begin(), initial_data.end()); DataNDC data(initial_data.begin(), initial_data.end());
CHECK_THROW(data.insert(std::make_pair(10, N10)), etl::flat_map_full); CHECK_THROW(data.insert(ETL_MAKE_PAIR(10, N10)), etl::flat_map_full);
} }
//************************************************************************* //*************************************************************************
@ -747,7 +749,7 @@ namespace
Compare1 compare; Compare1 compare;
Data1 data; Data1 data;
std::pair<Data1::iterator, bool> result; ETL_PAIR<Data1::iterator, bool> result;
result = data.emplace(0, "0"); result = data.emplace(0, "0");
compare.emplace(0, D1("0")); compare.emplace(0, D1("0"));
@ -760,8 +762,8 @@ namespace
CHECK(result.second); CHECK(result.second);
CHECK(*result.first == Element1(0, D1("0"))); CHECK(*result.first == Element1(0, D1("0")));
result = data.emplace(std::make_pair(2, D1("2"))); result = data.emplace(ETL_MAKE_PAIR(2, D1("2")));
compare.emplace(std::make_pair(2, D1("2"))); compare.emplace(ETL_MAKE_PAIR(2, D1("2")));
isEqual = Check_Equal(data.begin(), isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -792,7 +794,7 @@ namespace
Compare2 compare; Compare2 compare;
Data2 data; Data2 data;
std::pair<Data2::iterator, bool> result; ETL_PAIR<Data2::iterator, bool> result;
result = data.emplace(0, "0", "1"); result = data.emplace(0, "0", "1");
compare.emplace(0, D2("0", "1")); compare.emplace(0, D2("0", "1"));
@ -805,8 +807,8 @@ namespace
CHECK(result.second); CHECK(result.second);
CHECK(*result.first == Element2(0, D2("0", "1"))); CHECK(*result.first == Element2(0, D2("0", "1")));
result = data.emplace(std::make_pair(2, D2("2", "3"))); result = data.emplace(ETL_MAKE_PAIR(2, D2("2", "3")));
compare.emplace(std::make_pair(2, D2("2", "3"))); compare.emplace(ETL_MAKE_PAIR(2, D2("2", "3")));
isEqual = Check_Equal(data.begin(), isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -837,7 +839,7 @@ namespace
Compare3 compare; Compare3 compare;
Data3 data; Data3 data;
std::pair<Data3::iterator, bool> result; ETL_PAIR<Data3::iterator, bool> result;
result = data.emplace(0, "0", "1", "2"); result = data.emplace(0, "0", "1", "2");
compare.emplace(0, D3("0", "1", "2")); compare.emplace(0, D3("0", "1", "2"));
@ -850,8 +852,8 @@ namespace
CHECK(result.second); CHECK(result.second);
CHECK(*result.first == Element3(0, D3("0", "1", "2"))); CHECK(*result.first == Element3(0, D3("0", "1", "2")));
result = data.emplace(std::make_pair(2, D3("2", "3", "4"))); result = data.emplace(ETL_MAKE_PAIR(2, D3("2", "3", "4")));
compare.emplace(std::make_pair(2, D3("2", "3", "4"))); compare.emplace(ETL_MAKE_PAIR(2, D3("2", "3", "4")));
isEqual = Check_Equal(data.begin(), isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -882,7 +884,7 @@ namespace
Compare4 compare; Compare4 compare;
Data4 data; Data4 data;
std::pair<Data4::iterator, bool> result; ETL_PAIR<Data4::iterator, bool> result;
result = data.emplace(0, "0", "1", "2", "3"); result = data.emplace(0, "0", "1", "2", "3");
compare.emplace(0, D4("0", "1", "2", "3")); compare.emplace(0, D4("0", "1", "2", "3"));
@ -895,8 +897,8 @@ namespace
CHECK(result.second); CHECK(result.second);
CHECK(*result.first == Element4(0, D4("0", "1", "2", "3"))); CHECK(*result.first == Element4(0, D4("0", "1", "2", "3")));
result = data.emplace(std::make_pair(2, D4("2", "3", "4", "5"))); result = data.emplace(ETL_MAKE_PAIR(2, D4("2", "3", "4", "5")));
compare.emplace(std::make_pair(2, D4("2", "3", "4", "5"))); compare.emplace(ETL_MAKE_PAIR(2, D4("2", "3", "4", "5")));
isEqual = Check_Equal(data.begin(), isEqual = Check_Equal(data.begin(),
data.end(), data.end(),
@ -1147,8 +1149,8 @@ namespace
Compare_DataNDC compare_data(initial_data.begin(), initial_data.end()); Compare_DataNDC compare_data(initial_data.begin(), initial_data.end());
DataNDC data(initial_data.begin(), initial_data.end()); DataNDC data(initial_data.begin(), initial_data.end());
std::pair<Compare_DataNDC::iterator, Compare_DataNDC::iterator> i_compare = compare_data.equal_range(5); ETL_PAIR<Compare_DataNDC::iterator, Compare_DataNDC::iterator> i_compare = compare_data.equal_range(5);
std::pair<DataNDC::iterator, DataNDC::iterator> i_data = data.equal_range(5); ETL_PAIR<DataNDC::iterator, DataNDC::iterator> i_data = data.equal_range(5);
CHECK_EQUAL(std::distance(compare_data.begin(), i_compare.first), std::distance(data.begin(), i_data.first)); CHECK_EQUAL(std::distance(compare_data.begin(), i_compare.first), std::distance(data.begin(), i_data.first));
CHECK_EQUAL(std::distance(compare_data.begin(), i_compare.second), std::distance(data.begin(), i_data.second)); CHECK_EQUAL(std::distance(compare_data.begin(), i_compare.second), std::distance(data.begin(), i_data.second));
@ -1160,9 +1162,9 @@ namespace
Compare_DataNDC compare_data(initial_data.begin(), initial_data.end()); Compare_DataNDC compare_data(initial_data.begin(), initial_data.end());
DataNDC data(initial_data.begin(), initial_data.end()); DataNDC data(initial_data.begin(), initial_data.end());
std::pair<Compare_DataNDC::iterator, Compare_DataNDC::iterator> i_compare; ETL_PAIR<Compare_DataNDC::iterator, Compare_DataNDC::iterator> i_compare;
std::pair<DataNDC::iterator, DataNDC::iterator> i_data; ETL_PAIR<DataNDC::iterator, DataNDC::iterator> i_data;
i_data = data.equal_range(-1); i_data = data.equal_range(-1);
CHECK_EQUAL(data.begin(), i_data.first); CHECK_EQUAL(data.begin(), i_data.first);

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