fail_function.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. // Copyright (c) 2001-2011 Joel de Guzman
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_SPIRIT_KARMA_DETAIL_FAIL_FUNCTION_HPP
  7. #define BOOST_SPIRIT_KARMA_DETAIL_FAIL_FUNCTION_HPP
  8. #if defined(_MSC_VER)
  9. #pragma once
  10. #endif
  11. #include <boost/spirit/home/support/unused.hpp>
  12. #include <boost/config.hpp>
  13. namespace boost { namespace spirit { namespace karma { namespace detail
  14. {
  15. #ifdef _MSC_VER
  16. # pragma warning(push)
  17. # pragma warning(disable: 4512) // assignment operator could not be generated.
  18. #endif
  19. template <typename OutputIterator, typename Context, typename Delimiter>
  20. struct fail_function
  21. {
  22. typedef Context context_type;
  23. fail_function(OutputIterator& sink_, Context& context_
  24. , Delimiter const& delim_)
  25. : sink(sink_), ctx(context_), delim(delim_)
  26. {}
  27. template <typename Component, typename Attribute>
  28. bool operator()(Component const& component, Attribute const& attr) const
  29. {
  30. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
  31. (void)component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
  32. #endif
  33. // return true if any of the generators fail
  34. return !component.generate(sink, ctx, delim, attr);
  35. }
  36. template <typename Component>
  37. bool operator()(Component const& component) const
  38. {
  39. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
  40. (void)component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
  41. #endif
  42. // return true if any of the generators fail
  43. return !component.generate(sink, ctx, delim, unused);
  44. }
  45. OutputIterator& sink;
  46. Context& ctx;
  47. Delimiter const& delim;
  48. };
  49. #ifdef _MSC_VER
  50. # pragma warning(pop)
  51. #endif
  52. }}}}
  53. #endif