string_length.hpp 951 B

123456789101112131415161718192021222324252627282930
  1. /*=============================================================================
  2. Copyright (c) 2004 Joel de Guzman
  3. http://spirit.sourceforge.net/
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #if !defined(SPIRIT_TEST_IMPL_STRING_LEN_HPP)
  9. #define SPIRIT_TEST_IMPL_STRING_LEN_HPP
  10. // We use our own string_len function instead of std::strlen
  11. // to avoid the namespace confusion on different compilers. Some
  12. // have it in namespace std. Some have it in global namespace.
  13. // Some have it in both.
  14. namespace test_impl
  15. {
  16. template <typename Char>
  17. inline unsigned int
  18. string_length(Char const* str)
  19. {
  20. unsigned int len = 0;
  21. while (*str++)
  22. ++len;
  23. return len;
  24. }
  25. }
  26. #endif