From 0a7c9973496d73da87fb4e88de5a267c6d589da5 Mon Sep 17 00:00:00 2001 From: ipknHama Date: Fri, 20 Feb 2015 11:47:51 +0900 Subject: working on VS2013 support * wrap constexpr * add run-time version of get_parameter_tag --- include/common.h | 3 ++- include/utility.h | 43 +++++++++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/include/common.h b/include/common.h index 619f4d5..8808d6a 100644 --- a/include/common.h +++ b/include/common.h @@ -109,6 +109,7 @@ namespace crow } } +#ifndef CROW_MSVC_WORKAROUND constexpr crow::HTTPMethod operator "" _method(const char* str, size_t len) { return @@ -122,4 +123,4 @@ constexpr crow::HTTPMethod operator "" _method(const char* str, size_t len) crow::black_magic::is_equ_p(str, "TRACE", 5) ? crow::HTTPMethod::TRACE : throw std::runtime_error("invalid http method"); }; - +#endif diff --git a/include/utility.h b/include/utility.h index 65d4cf8..d1dda06 100644 --- a/include/utility.h +++ b/include/utility.h @@ -4,11 +4,14 @@ #include #include #include +#include +#include namespace crow { namespace black_magic { +#ifndef CROW_MSVC_WORKAROUND struct OutOfRange { OutOfRange(unsigned pos, unsigned length) {} @@ -44,15 +47,6 @@ namespace crow } }; - unsigned find_closing_tag_runtime(const char* s, unsigned p) - { - return - s[p] == 0 - ? throw std::runtime_error("unmatched tag <") : - s[p] == '>' - ? p : find_closing_tag_runtime(s, p+1); - } - constexpr unsigned find_closing_tag(const_str s, unsigned p) { return s[p] == '>' ? p : find_closing_tag(s, p+1); @@ -124,7 +118,7 @@ namespace crow { return is_equ_n(s, i, "", 0, 6); } - +#endif template struct paramater_tag { @@ -184,28 +178,38 @@ struct paramater_tag \ return is_paramter_tag_compatible(a/6, b/6); } - constexpr uint64_t get_parameter_tag_runtime(const char* s, unsigned p = 0) + unsigned find_closing_tag_runtime(const char* s, unsigned p) + { + return + s[p] == 0 + ? throw std::runtime_error("unmatched tag <") : + s[p] == '>' + ? p : find_closing_tag_runtime(s, p + 1); + } + + uint64_t get_parameter_tag_runtime(const char* s, unsigned p = 0) { return s[p] == 0 ? 0 : s[p] == '<' ? ( - strncmp(s+p, "", 5) == 0 + std::strncmp(s+p, "", 5) == 0 ? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 1 : - strncmp(s+p, "", 6) == 0 + std::strncmp(s+p, "", 6) == 0 ? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 2 : - (strncmp(s+p, "", 7) == 0 || - strncmp(s+p, "", 8) == 0) + (std::strncmp(s+p, "", 7) == 0 || + std::strncmp(s+p, "", 8) == 0) ? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 3 : - (strncmp(s+p, "", 5) == 0 || - strncmp(s+p, "", 8) == 0) + (std::strncmp(s+p, "", 5) == 0 || + std::strncmp(s+p, "", 8) == 0) ? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 4 : - strncmp(s+p, "", 6) == 0 + std::strncmp(s+p, "", 6) == 0 ? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 5 : throw std::runtime_error("invalid parameter type") ) : get_parameter_tag_runtime(s, p+1); } +#ifndef CROW_MSVC_WORKAROUND constexpr uint64_t get_parameter_tag(const_str s, unsigned p = 0) { return @@ -226,6 +230,7 @@ struct paramater_tag \ ) : get_parameter_tag(s, p+1); } +#endif template struct S @@ -448,6 +453,7 @@ template template struct function_traits; +#ifndef CROW_MSVC_WORKAROUND template struct function_traits : public function_traits { @@ -458,6 +464,7 @@ template using arg = typename parent_t::template arg; }; +#endif template struct function_traits -- cgit v1.2.3-54-g00ecf