Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/modules/ROOT/pages/examples.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Error Detected: Overflow detected in unsigned addition
====
[source, c++]
----
include::example$basic_usage_stacktrace.cpp[]
include::example$basic_usage_stacktrace.cpp[tags=**;!exclude]
----

Output on Linux x64:
Expand Down Expand Up @@ -263,7 +263,7 @@ The example approximates the same effect with a type alias so it compiles either
====
[source, c++]
----
include::example$safety_profile.cpp[]
include::example$safety_profile.cpp[tags=**;!exclude]
----

Output without `BOOST_SAFE_NUMBERS_INTEGER_SAFETY_PROFILE` (silent wrap-around):
Expand Down Expand Up @@ -342,7 +342,7 @@ IMPORTANT: The header `<boost/safe_numbers/fmt_format.hpp>` is *NOT* part of the
====
[source, c++]
----
include::example$fmt_format.cpp[]
include::example$fmt_format.cpp[tags=**;!exclude]
----

Output:
Expand Down
8 changes: 8 additions & 0 deletions examples/basic_usage_stacktrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <boost/safe_numbers/unsigned_integers.hpp> // For safe_numbers types
#include <boost/safe_numbers/iostream.hpp> // For safe_numbers <iostream> support
#include <boost/exception/diagnostic_information.hpp> // For boost::diagnostic_information
// tag::exclude[]

#if (defined(__x86_64__) || defined(_M_X64)) && !defined(__MINGW32__) && !defined(__CYGWIN__)

Expand All @@ -16,10 +17,13 @@
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif

// end::exclude[]
#include <boost/stacktrace.hpp> // For boost::stacktrace::from_current_exception
// tag::exclude[]

#endif

// end::exclude[]
#include <iostream>
#include <cstdint>

Expand All @@ -41,7 +45,9 @@ int main()
// at the throw site. boost::diagnostic_information extracts all of it.
std::cerr << boost::diagnostic_information(e) << std::endl;

// tag::exclude[]
#if (defined(__x86_64__) || defined(_M_X64)) && !defined(__MINGW32__) && !defined(__CYGWIN__)
// end::exclude[]
// On x86_64, boost::stacktrace can capture the throw-site stacktrace
// from the current exception via from_current_exception().
// This requires linking with boost_stacktrace_from_exception.
Expand All @@ -50,7 +56,9 @@ int main()
{
std::cerr << "Stacktrace:\n" << st << std::endl;
}
// tag::exclude[]
#endif
// end::exclude[]
}

return 0;
Expand Down
4 changes: 4 additions & 0 deletions examples/fmt_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

// tag::exclude[]
#define FMT_HEADER_ONLY

#if __has_include(<fmt/format.h>)

// end::exclude[]
#include <boost/safe_numbers/unsigned_integers.hpp>
#include <boost/safe_numbers/bounded_integers.hpp>
#include <boost/safe_numbers/fmt_format.hpp>
Expand Down Expand Up @@ -62,6 +64,7 @@ int main()

return 0;
}
// tag::exclude[]

#else

Expand All @@ -73,3 +76,4 @@ int main()
}

#endif
// end::exclude[]
2 changes: 2 additions & 0 deletions examples/safety_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
#include <iostream>
#include <cstdint>
#include <limits>
// tag::exclude[]

#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4127) // Conditional expression is constant
#endif
// end::exclude[]

#ifdef BOOST_SAFE_NUMBERS_INTEGER_SAFETY_PROFILE
using u32 = boost::safe_numbers::u32;
Expand Down
Loading