default.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright Daniel Wallin, David Abrahams 2005. Use, modification and
  2. // distribution is subject to the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef DEFAULT_050329_HPP
  6. # define DEFAULT_050329_HPP
  7. # include <boost/detail/workaround.hpp>
  8. namespace boost { namespace parameter { namespace aux {
  9. // A wrapper for the default value passed by the user when resolving
  10. // the value of the parameter with the given Keyword
  11. template <class Keyword, class Value>
  12. struct default_
  13. {
  14. default_(Value& x)
  15. : value(x)
  16. {}
  17. Value& value;
  18. };
  19. //
  20. // lazy_default --
  21. //
  22. // A wrapper for the default value computation function passed by
  23. // the user when resolving the value of the parameter with the
  24. // given keyword
  25. //
  26. # if BOOST_WORKAROUND(__EDG_VERSION__, <= 300)
  27. // These compilers need a little extra help with overload
  28. // resolution; we have empty_arg_list's operator[] accept a base
  29. // class to make that overload less preferable.
  30. template <class KW, class DefaultComputer>
  31. struct lazy_default_base
  32. {
  33. lazy_default_base(DefaultComputer const& x)
  34. : compute_default(x)
  35. {}
  36. DefaultComputer const& compute_default;
  37. };
  38. template <class KW, class DefaultComputer>
  39. struct lazy_default
  40. : lazy_default_base<KW,DefaultComputer>
  41. {
  42. lazy_default(DefaultComputer const & x)
  43. : lazy_default_base<KW,DefaultComputer>(x)
  44. {}
  45. };
  46. # define BOOST_PARAMETER_lazy_default_fallback lazy_default_base
  47. # else
  48. template <class KW, class DefaultComputer>
  49. struct lazy_default
  50. {
  51. lazy_default(const DefaultComputer& x)
  52. : compute_default(x)
  53. {}
  54. DefaultComputer const& compute_default;
  55. };
  56. # define BOOST_PARAMETER_lazy_default_fallback lazy_default
  57. # endif
  58. }}} // namespace boost::parameter::aux
  59. #endif // DEFAULT_050329_HPP