unused_delimiter.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #if !defined(BOOST_SPIRIT_KARMA_UNUSED_DELIMITER_MAR_15_2009_0923PM)
  6. #define BOOST_SPIRIT_KARMA_UNUSED_DELIMITER_MAR_15_2009_0923PM
  7. #if defined(_MSC_VER)
  8. #pragma once
  9. #endif
  10. #include <boost/spirit/home/support/unused.hpp>
  11. namespace boost { namespace spirit { namespace karma { namespace detail
  12. {
  13. #ifdef _MSC_VER
  14. # pragma warning(push)
  15. # pragma warning(disable: 4512) // assignment operator could not be generated.
  16. #endif
  17. template <typename Delimiter>
  18. struct unused_delimiter : unused_type
  19. {
  20. unused_delimiter(Delimiter const& delim)
  21. : delimiter(delim) {}
  22. Delimiter const& delimiter;
  23. };
  24. #ifdef _MSC_VER
  25. # pragma warning(pop)
  26. #endif
  27. // If a surrounding verbatim[] directive was specified, the current
  28. // delimiter is of the type unused_delimiter. In this case we
  29. // re-activate the delimiter which was active before the verbatim[]
  30. // directive.
  31. template <typename Delimiter, typename Default>
  32. inline Delimiter const&
  33. get_delimiter(unused_delimiter<Delimiter> const& u, Default const&)
  34. {
  35. return u.delimiter;
  36. }
  37. // If no surrounding verbatim[] directive was specified we activate
  38. // a single space as the delimiter to use.
  39. template <typename Delimiter, typename Default>
  40. inline Default const&
  41. get_delimiter(Delimiter const&, Default const& d)
  42. {
  43. return d;
  44. }
  45. }}}}
  46. #endif