is boost::container::static_vector header only library?
I am working on a embedded systems project, where we are exploring options to use STL containers without dynamic memory allocation, except std::array we cannot use any of the STL, boost container has static_vector for that, on browsing the code,we found that the library has to be built, is there a way to use this library as header only library?
Sivaram L Via Boost-users wrote:
I am working on a embedded systems project, where we are exploring options to use STL containers without dynamic memory allocation, except std::array we cannot use any of the STL, boost container has static_vector for that, on browsing the code,we found that the library has to be built, is there a way to use this library as header only library? Boost.Container's static_vector as well as STL containers are header-only.
From: https://www.boost.org/doc/libs/1_69_0/doc/html/container.html#container.intr... There is no need to compile Boost.Container, since it's a header-only library, just include your Boost header directory in your compiler include path except if you use: - Extended Allocators - Some Polymorphic Memory Resources classes. If you need some alternative, you can find similar container in Boost.Geometry: boost::geometry::index::detail::varray see: https://github.com/boostorg/geometry/blob/develop/include/boost/geometry/ind... but it depends on Boost.Container so you'd need this library anyway. Adam
On Wed, 16 Jan 2019 at 16:43, Sivaram L via Boost-users < boost-users@lists.boost.org> wrote:
I am working on a embedded systems project, where we are exploring options to use STL containers without dynamic memory allocation
You could look into the ETL (Embedded Template Library), they [it] provides what you need for your purpose: https://github.com/ETLCPP/etl . *Summary* The ETL is not designed to completely replace the STL, but complement it. Its design objective covers three areas. - Create a set of containers where the size or maximum size is determined at compile time. These containers are direct equivalents of those supplied in the STL. - Be compatible with C++ 03 but implement as many of the C++ 11 additions as possible. - Add other useful components that are not present in the standard library. The embedded template library has been designed for lower resource embedded applications. It contains a set of containers, algorithms and utilities, some of which emulate parts of the STL. There is no dynamic memory allocation. The library makes no use of the heap. All of the containers have a fixed capacity allowing all memory allocation to be determined at compile time. The library is intended for any compiler that supports C++ 03. degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*
Hi,
has to be built, is there a way to use this library as header only library?
When I use boost, I usually don't link any pre-compiled libraries. I get undefined symbols at link time and I can add the missing boost source files for those undefined symbols. Most of the time I have to add libs\system\src\error_code.cpp. On Windows I #define BOOST_ALL_NO_LIB to disable the linker from automatically linking the boost libraries. Note: When using boost::thread on Windows in a DLL, I have to add calls to boost::on_process_enter(), boost::on_thread_enter(), boost::on_thread_exit() and boost::on_process_exit() in DllMain() and provide an empty boost::tss_cleanup_implemented(). This way the boost sources are always compiled with the same compiler options as the rest of my code. I am not sure, whether this approach really works with all boost libraries on all supported platforms. I only use a limited subset (smart pointers, noncopyable, lexical_cast, bind, function, thread, asio, filesystem, regex) on windows, Linux, MacOSX and iOS. I hope this can help. 73, Mario
On 16/01/2019 13:44, Sivaram L via Boost-users wrote:
I am working on a embedded systems project, where we are exploring options to use STL containers without dynamic memory allocation, except std::array we cannot use any of the STL, boost container has static_vector for that, on browsing the code,we found that the library has to be built, is there a way to use this library as header only library?
As Adam has correctly pointed out, boost::container::static_vector is header-only. Ion
participants (5)
-
Adam Wulkiewicz
-
degski
-
Ion Gaztañaga
-
Klebsch, Mario
-
Sivaram L