is boost::container::static_vector header only library?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

is boost::container::static_vector header only library?

Boost - Users mailing list
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-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: is boost::container::static_vector header only library?

Boost - Users mailing list
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.intro.introduction_building_container

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/index/detail/varray.hpp#L153
but it depends on Boost.Container so you'd need this library anyway.

Adam

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: is boost::container::static_vector header only library?

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On Wed, 16 Jan 2019 at 16:43, Sivaram L via Boost-users <[hidden email]> 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

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: is boost::container::static_vector header only library?

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
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

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: is boost::container::static_vector header only library?

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
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


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users