protected_call.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. *
  3. * Copyright (c) 2004
  4. * John Maddock
  5. *
  6. * Use, modification and distribution are subject to the
  7. * Boost Software License, Version 1.0. (See accompanying file
  8. * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. *
  10. */
  11. /*
  12. * LOCATION: see http://www.boost.org for most recent version.
  13. * FILE basic_regex_creator.cpp
  14. * VERSION see <boost/version.hpp>
  15. * DESCRIPTION: Declares template class basic_regex_creator which fills in
  16. * the data members of a regex_data object.
  17. */
  18. #ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP
  19. #define BOOST_REGEX_V4_PROTECTED_CALL_HPP
  20. #include <boost/config.hpp>
  21. #ifdef BOOST_MSVC
  22. #pragma warning(push)
  23. #pragma warning(disable: 4103)
  24. #endif
  25. #ifdef BOOST_HAS_ABI_HEADERS
  26. # include BOOST_ABI_PREFIX
  27. #endif
  28. #ifdef BOOST_MSVC
  29. #pragma warning(pop)
  30. #endif
  31. namespace boost{
  32. namespace BOOST_REGEX_DETAIL_NS{
  33. class BOOST_REGEX_DECL abstract_protected_call
  34. {
  35. public:
  36. bool BOOST_REGEX_CALL execute()const;
  37. // this stops gcc-4 from complaining:
  38. virtual ~abstract_protected_call(){}
  39. private:
  40. virtual bool call()const = 0;
  41. };
  42. template <class T>
  43. class concrete_protected_call
  44. : public abstract_protected_call
  45. {
  46. public:
  47. typedef bool (T::*proc_type)();
  48. concrete_protected_call(T* o, proc_type p)
  49. : obj(o), proc(p) {}
  50. private:
  51. bool call()const BOOST_OVERRIDE;
  52. T* obj;
  53. proc_type proc;
  54. };
  55. template <class T>
  56. bool concrete_protected_call<T>::call()const
  57. {
  58. return (obj->*proc)();
  59. }
  60. }
  61. } // namespace boost
  62. #ifdef BOOST_MSVC
  63. #pragma warning(push)
  64. #pragma warning(disable: 4103)
  65. #endif
  66. #ifdef BOOST_HAS_ABI_HEADERS
  67. # include BOOST_ABI_SUFFIX
  68. #endif
  69. #ifdef BOOST_MSVC
  70. #pragma warning(pop)
  71. #endif
  72. #endif