identity_element.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2008-2009: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. #ifndef BOOST_ICL_TYPE_TRAITS_IDENTITY_ELEMENT_HPP_JOFA_080912
  9. #define BOOST_ICL_TYPE_TRAITS_IDENTITY_ELEMENT_HPP_JOFA_080912
  10. #include <boost/icl/type_traits/type_to_string.hpp>
  11. namespace boost{ namespace icl
  12. {
  13. template <class Type> struct identity_element
  14. {
  15. static Type value();
  16. Type operator()()const { return value(); }
  17. };
  18. template <class Type>
  19. inline Type identity_element<Type>::value()
  20. {
  21. static Type _value;
  22. return _value;
  23. }
  24. template<>
  25. inline std::string unary_template_to_string<identity_element>::apply() { return "0"; }
  26. }} // namespace boost icl
  27. #endif