Primer is header only -- this means that to use Primer in a C++ project,
its include directory needs
to be added to your include search path.
This includes the primer
subfolder, as well as two extra libraries visit_struct
and weak_ref. These both
stand alone and are potentially useful outside of Primer, but they are small
enough to justify distributing them with Primer.
The core of Primer may be included with
#include <primer/primer.hpp>
To enable support for individual standard and boost containers, you may include any of the extra headers
#include <primer/std/vector.hpp> #include <primer/std/set.hpp> ... #include <primer/boost/optional.hpp> ...
or include all standard container headers or all boost container headers with
#include <primer/std.hpp> #include <primer/boost.hpp>
To include both visit_struct
and the related support headers in primer, you may include
#include <primer/visit_struct.hpp>
To use the features of primer that require lua-eris, which live in the api namespace, you may include
#include <primer/api.hpp>
You may include forward declarations of the core types via
#include <primer/primer_fwd.hpp>
If you only want to get the primer::error
or primer::expected types, without pulling in the
rest of primer, you may include
#include <primer/error.hpp> #include <primer/expected.hpp>
and forward declarations of these:
#include <primer/expected_fwd.hpp>
Pulling those in is very lightweight, they only rely on e.g. <new>,
<string> and <utility>.
If you just want to get the version number of primer, you may include
#include <primer/version.hpp>
Finally, if you would like to include lua or eris using exactly the same headers that Primer does internally, you may include
#include <primer/lua.hpp>
or
#include <primer/eris.hpp>
Primer searches for its configuration defines in <primer/conf.hpp>
![]() |
Note |
|---|---|
All other headers are considered implementation details, and may be moved or nonexistant in future releases, so you shouldn't include them directly. |
Primer responds to a few configuration defines:
|
symbol |
effect |
|---|---|
|
|
This is used to enable internal assertions that Primer uses to
check its integrity. Especially, lua stack discipline assertions.
You can turn these on if you are having strange lua errors, they
may reveal stack discipline problems in usre specializations of
|
|
|
This should be used if lua is being compiled as C++ rather than
as C in your project. It causes primer not to use |
|
|
Disables all static assertions made by Primer. |
|
|
Disables all try / catch blocks in primer. Use this if you want
to compile with |
|
|
Tells primer to use, as an optimization assumption, that lua memory
allocation will never fail, and, that when populating |
![]() |
Caution |
|---|---|
|
Several data structures and functions in Primer make assumptions that types used with them do not throw exceptions when default constructed, moved, etc. These assumptions are generally true for most user types and standard library types that they would be used with.
However, if you are using an old compiler with an old version of the standard
library, crucial constructors for objects like
To disable the safety checks, you can define In general the failure of the conditions checked by these assertions can lead to undefined behavior. |
![]() |
Note |
|---|---|
If lua is compiled as C, i.e., |
To enable these, you can add them in your build system, define them in your
source files before including primer, or create a custom version of <primer/conf.hpp>.