fail_function.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #if !defined(SPIRIT_KARMA_SEQUENCE_FEB_28_2007_0249PM)
  7. #define SPIRIT_KARMA_SEQUENCE_FEB_28_2007_0249PM
  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. template <typename OutputIterator, typename Context, typename Delimiter>
  16. struct fail_function
  17. {
  18. typedef Context context_type;
  19. fail_function(OutputIterator& sink_, Context& context_
  20. , Delimiter const& delim_)
  21. : sink(sink_), ctx(context_), delim(delim_)
  22. {}
  23. template <typename Component, typename Attribute>
  24. bool operator()(Component const& component, Attribute const& attr) const
  25. {
  26. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
  27. component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
  28. #endif
  29. // return true if any of the generators fail
  30. return !component.generate(sink, ctx, delim, attr);
  31. }
  32. template <typename Component>
  33. bool operator()(Component const& component) const
  34. {
  35. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
  36. component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
  37. #endif
  38. // return true if any of the generators fail
  39. return !component.generate(sink, ctx, delim, unused);
  40. }
  41. OutputIterator& sink;
  42. Context& ctx;
  43. Delimiter const& delim;
  44. // silence MSVC warning C4512: assignment operator could not be generated
  45. BOOST_DELETED_FUNCTION(fail_function& operator= (fail_function const&))
  46. };
  47. }}}}
  48. #endif