The Standard Template Library (STL) is used in a large number of C++ applications, but doesn't always get much of a look-in for many embedded projects, largely due to its use of the heap for many of its container classes.
I've added a library that, amongst other things, defines containers with statically allocated storage.
The library makes no use of the heap and does not utilise RTTI. All storage is defined at compile time. (It's also very cache friendly due to the storage for all containers being contiguous).
It does make use of some of the non-container aspects of the STL and therefore requires that a version of the STL is available to the Arduino project. A suitable implementation may be found here.
Apart from containers, the library provides many other templated features. To find out more visit www.etlcpp.com
(Be aware that the documentation is a little behind at the moment and doesn't mention some of the lastest hashing containers).
The library is intended to be generally useful across many platforms, and has been extensively unit tested (current count is 1154 tests) with Microsoft and GCC compilers. That said the amount of testing on the Arduino platform has so far been limited to a couple of simple examples on my Genuino Zero, so be prepared for possible compilation issues. If you find anything odd then raise it on the github page.
An example 'BlinkList' is supplied to get you started. This builds on the 'Blink' demo by creating two lists of delay times, and cycling through them consecutively.
To install it, search for 'Embedded Template Library' in the library manager.
The library has been developed slowly over several years, starting off as a personal library of 'good ideas' that I had been experimenting with. Eventually I decided to pull the code together as a library after I realised that there were no real open source (or even closed) alternatives that met my requirements. I think it would be a very useful resource for embedded programmers and I've had encouraging responses from other coders in the industry. The big problem is it is in a catch-22 situation where people are cautious about using a library in commercial products that isn't already widely used, and it isn't widely used because people are cautious!
As users of Arduino boards are likely to be up for a little bit more experimentation I thought that they would be more inclined to give it a try and hopefully give it a bit more exposure (and the extra beta testing would also be a plus).
I'm currently working on a string implementation and I have outline plans for a set of cache containers and a timer service class that will hook into a hardware timer, allowing for one-shot, and repeating timer callbacks.
In the long term I have tentative plans for a messaging system and a cooperative scheduler.
I installed the ETL library 8.1.0 by Library Manager.
created a new project "mytest_etl", and included the libray.
but can not pass the compiling.
Could you give me some advice? Thanks.
error as follows:
I'm getting the following error when trying to include "deque.h"
In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\iosfwd:21:0,
from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\iterator:35,
from C:\Users\Brad\Documents\Arduino\libraries\Embedded_Template_Library\src/deque.h:36,
from C:\Users\Brad\Documents\Arduino\snake\snake.ino:1:
C:\Users\Brad\Documents\Arduino\libraries\Embedded_Template_Library\src/char_traits.h:35:24: fatal error: algorithms.h: No such file or directory
#include "algorithms.h"
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
I have the port for STL from Andy Brown's site installed as well. Does this have anything to do with algorithm.h being in your library and you including algorithms.h?
Added pointer specialisation for etl::vector thereby reducing code size when using multiple instances of vectors of differing pointer types.
Modified the library for greater cross compiler compatibility.
Added a method of definition of typesafe typedefs
The problem
typedef int event_id_t;
typedef int command_id_t;
event_id_t event;
command_id_t command;
event = command; [b][color=red]// OOPS!, Run time error. :-([/color][/b]
Has anyone been able to use Embedded Template Library on Arduino successfully?
I am trying to use it, but there so many issues. So, I wonder what kind of experience the others had with it.
Arduino:1.8.1 (Windows 10),Board: "Arduino/Genuino Uno"
error as follows:
In file included from C:\Users\zhuang\Documents\Arduino\libraries\Embedded_Template_Library\src/pool.h:37:0,
from C:\Users\zhuang\Documents\Arduino\libraries\Embedded_Template_Library\src/private/list_base.h:39,
from C:\Users\zhuang\Documents\Arduino\libraries\Embedded_Template_Library\src/ilist.h:42,
from C:\Users\zhuang\Documents\Arduino\libraries\Embedded_Template_Library\src/list.h:36,
from C:\Users\zhuang\Documents\Arduino\libraries\Embedded_Template_Library\examples\BlinkList\BlinkList.ino:8:
C:\Users\zhuang\Documents\Arduino\libraries\Embedded_Template_Library\src/integral_limits.h:34:19: fatal error: climits: No such file or directory
#include
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
I have the port for STL from Andy Brown's site installed as well.
Could you give me some advice? Thanks.