protected_call.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifdef BOOST_MSVC
  21. #pragma warning(push)
  22. #pragma warning(disable: 4103)
  23. #endif
  24. #ifdef BOOST_HAS_ABI_HEADERS
  25. # include BOOST_ABI_PREFIX
  26. #endif
  27. #ifdef BOOST_MSVC
  28. #pragma warning(pop)
  29. #endif
  30. namespace boost{
  31. namespace BOOST_REGEX_DETAIL_NS{
  32. class BOOST_REGEX_DECL abstract_protected_call
  33. {
  34. public:
  35. bool BOOST_REGEX_CALL execute()const;
  36. // this stops gcc-4 from complaining:
  37. virtual ~abstract_protected_call(){}
  38. private:
  39. virtual bool call()const = 0;
  40. };
  41. template <class T>
  42. class concrete_protected_call
  43. : public abstract_protected_call
  44. {
  45. public:
  46. typedef bool (T::*proc_type)();
  47. concrete_protected_call(T* o, proc_type p)
  48. : obj(o), proc(p) {}
  49. private:
  50. virtual bool call()const;
  51. T* obj;
  52. proc_type proc;
  53. };
  54. template <class T>
  55. bool concrete_protected_call<T>::call()const
  56. {
  57. return (obj->*proc)();
  58. }
  59. }
  60. } // namespace boost
  61. #ifdef BOOST_MSVC
  62. #pragma warning(push)
  63. #pragma warning(disable: 4103)
  64. #endif
  65. #ifdef BOOST_HAS_ABI_HEADERS
  66. # include BOOST_ABI_SUFFIX
  67. #endif
  68. #ifdef BOOST_MSVC
  69. #pragma warning(pop)
  70. #endif
  71. #endif