Skip to content

Commit

Permalink
Make dependency on Boost.TypeIndex optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzlaine committed Sep 20, 2020
1 parent 113270d commit 675fcd2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
9 changes: 9 additions & 0 deletions include/boost/parser/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
disable the use of concepts, define this macro. */
# define BOOST_PARSER_DISABLE_CONCEPTS

/** Define this macro to remove all Boost dependencies from Boost.Parser. */
# define BOOST_PARSER_STANDALONE

#else

# ifdef BOOST_PARSER_NO_RUNTIME_ASSERTIONS
Expand All @@ -48,4 +51,10 @@
#define BOOST_PARSER_USE_CONCEPTS 0
#endif

#if !defined(BOOST_PARSER_STANDALONE)
#define BOOST_PARSER_USE_BOOST 1
#else
#define BOOST_PARSER_USE_BOOST 0
#endif

#endif
26 changes: 20 additions & 6 deletions include/boost/parser/detail/printing_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@

#include <boost/parser/detail/printing.hpp>

#if BOOST_PARSER_USE_BOOST
#include <boost/type_index.hpp>
#else
#include <typeinfo>
#endif


namespace boost { namespace parser { namespace detail {

template<typename T>
auto type_name()
{
#if BOOST_PARSER_USE_BOOST
return typeindex::type_id<T>().pretty_name();
#else
return typeid(T).name();
#endif
}

template<typename Parser>
struct n_aray_parser : std::false_type
{};
Expand Down Expand Up @@ -324,7 +338,7 @@ namespace boost { namespace parser { namespace detail {
std::ostream & os,
int components)
{
os << "symbols<" << typeindex::type_id<T>().pretty_name() << ">";
os << "symbols<" << detail::type_name<T>() << ">";
}

template<typename Context, typename Predicate>
Expand Down Expand Up @@ -635,8 +649,8 @@ namespace boost { namespace parser { namespace detail {
return;
}
}
os << "uint<" << typeindex::type_id<T>().pretty_name() << ", " << Radix
<< ", " << MinDigits << ", " << MaxDigits << ">";
os << "uint<" << detail::type_name<T>() << ", " << Radix << ", "
<< MinDigits << ", " << MaxDigits << ">";
detail::print_expected(context, os, parser.expected_);
}

Expand Down Expand Up @@ -672,8 +686,8 @@ namespace boost { namespace parser { namespace detail {
return;
}
}
os << "int<" << typeindex::type_id<T>().pretty_name() << ", " << Radix
<< ", " << MinDigits << ", " << MaxDigits << ">";
os << "int<" << detail::type_name<T>() << ", " << Radix << ", "
<< MinDigits << ", " << MaxDigits << ">";
detail::print_expected(context, os, parser.expected_);
}

Expand Down Expand Up @@ -714,7 +728,7 @@ namespace boost { namespace parser { namespace detail {
std::ostream & os,
int components)
{
os << "float<" << typeindex::type_id<T>().pretty_name() << ">";
os << "float<" << detail::type_name<T>() << ">";
}

template<typename Context>
Expand Down

0 comments on commit 675fcd2

Please sign in to comment.