diff --git a/README.md b/README.md index 2c7c1908..9f5b56c5 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Embedded Template Library (ETL) **Motivation** -C++ is a great language to use for embedded applications and templates are a powerful aspect. The standard library can offer a great deal of well tested functionality, but there are some parts of the standard library that do not fit well with deterministic behaviour and limited resource requirements. These limitations usually preclude the use of dynamically allocated memory and open ended sized containers. +C++ is a great language to use for embedded applications and templates are a powerful aspect. The standard library can offer a great deal of well tested functionality, but there are some parts of the standard library that do not fit well with deterministic behaviour and limited resource requirements. These limitations usually preclude the use of dynamically allocated memory and containers with open ended sizes. What is needed is a template library where the user can declare the size, or maximum size of any object upfront. Most embedded compilers do not currently support the standard beyond C++ 03, therefore excluding the programmer from using the enhanced features of the later library. @@ -25,14 +25,21 @@ The library is intended for any compiler that supports C++ 03. **Main features:** - - No dynamic memory allocation. - - A set of fixed capacity containers. (stack, queue, list, forward_list, vector, deque) - - Templated compile time constants. - - Templated design pattern base classes (Visitor, Observer) - - Reverse engineered C++ 0x11 features (type traits, algorithms, containers etc.) - - Smart enumerations - - 8, 16, 32 & 64 bit CRC calculations - - Many utilities for template support. - - Variants (a type that can store many types in a type-safe interface) - - Optional exceptions on errors. +- Cross platform. This library is not specific to any processor type. +- No dynamic memory allocation +- No RTTI required +- Very little use of virtual functions. They are used only when they are absolutely necessary for the required functionality +- A set of fixed capacity containers. (array, bitset, deque, forward_list, list, queue, stack, vector, map, set, etc.) +- As the storage for all of the container types is allocated as a contiguous block, they are extremely cache friendly +- Templated compile time constants +- Templated design pattern base classes (Visitor, Observer) +- Reverse engineered C++ 0x11 features (type traits, algorithms, containers etc.) +- Smart enumerations +- 8, 16, 32 & 64 bit CRC calculations +- Checksums & hash functions +- Variants (a type that can store many types in a type-safe interface) +- Choice of asserts, exceptions, error handler or no checks on errors +- Many utilities for template support. + +See (http://www.etlcpp.com) for up-to-date information. diff --git a/algorithm.h b/algorithm.h index 30d8ab90..f3afa52b 100644 --- a/algorithm.h +++ b/algorithm.h @@ -85,14 +85,14 @@ namespace etl typedef typename std::iterator_traits::value_type value_t; return etl::minmax_element(begin, end, std::less()); - } - + } + //*************************************************************************** /// minmax ///\ingroup algorithm /// //*************************************************************************** - template + template std::pair minmax(const T& a, const T& b) { return (b < a) ? std::pair(b, a) : std::pair(a, b); @@ -103,7 +103,7 @@ namespace etl ///\ingroup algorithm /// //*************************************************************************** - template + template std::pair minmax(const T& a, const T& b, TCompare compare) { return compare(b, a) ? std::pair(b, a) : std::pair(a, b); @@ -117,17 +117,17 @@ namespace etl template TIterator is_sorted_until(TIterator begin, TIterator end) { - if (begin != end) + if (begin != end) { TIterator next = begin; - while (++next != end) + while (++next != end) { if (*next < *begin) { return next; } - + ++begin; } } @@ -141,19 +141,19 @@ namespace etl /// //*************************************************************************** template - TIterator is_sorted_until(TIterator begin, TIterator end, TCompare compare) + TIterator is_sorted_until(TIterator begin, TIterator end, TCompare compare) { - if (begin != end) + if (begin != end) { TIterator next = begin; - while (++next != end) + while (++next != end) { if (compare(*next, *begin)) { return next; } - + ++begin; } } @@ -216,7 +216,7 @@ namespace etl { *out++ = *begin; } - + ++begin; } @@ -276,7 +276,7 @@ namespace etl { return std::find_if(begin, end, predicate) == end; } - + //*************************************************************************** /// is_permutation ///\ingroup algorithm @@ -291,7 +291,7 @@ namespace etl std::advance(end2, 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)) { @@ -307,7 +307,7 @@ namespace etl return true; } - + //*************************************************************************** /// is_permutation ///\ingroup algorithm @@ -318,7 +318,7 @@ namespace etl { if (begin1 != end1) { - for (TIterator1 i = begin1; i != end1; ++i) + for (TIterator1 i = begin1; i != end1; ++i) { if (i == std::find(begin1, i, *i)) { @@ -333,7 +333,7 @@ namespace etl } return true; - } + } //*************************************************************************** /// is_permutation @@ -349,7 +349,7 @@ namespace etl std::advance(end2, std::distance(begin1, end1)); - for (TIterator1 i = begin1; i != end1; ++i) + for (TIterator1 i = begin1; i != end1; ++i) { if (i == std::find_if(begin1, i, std::bind1st(predicate, *i))) { @@ -376,7 +376,7 @@ namespace etl { if (begin1 != end1) { - for (TIterator1 i = begin1; i != end1; ++i) + for (TIterator1 i = begin1; i != end1; ++i) { if (i == std::find_if(begin1, i, std::bind1st(predicate, *i))) { @@ -416,7 +416,7 @@ namespace etl return false; } } - + return true; } @@ -449,9 +449,9 @@ namespace etl //*************************************************************************** template std::pair partition_copy(TSource begin, - TSource end, + TSource end, TDestinationTrue destination_true, - TDestinationFalse destination_false, + TDestinationFalse destination_false, TUnaryPredicate predicate) { while (begin != end) diff --git a/enum_type.h b/enum_type.h index 4305a054..bd1a4d7c 100644 --- a/enum_type.h +++ b/enum_type.h @@ -73,7 +73,7 @@ SOFTWARE. /// std::cout << "Direction = " << direction.c_str(); // Prints "Direction = North" ///\endcode /// If a conversion to a string is not required then the 'ENUM_TYPE' declaration may be omitted. -/// In that case the c_str() function will return a "?". This will also be the case for any +/// In that case the c_str() function will return a "?". This will also be the case for any /// enumeration value that does not have an ENUM_TYPE entry. ///\ingroup utilities