| 955 | |
| 956 | template<typename T> |
| 957 | StatusWithReason fromString(const std::string& from, T* & to) |
| 958 | { |
| 959 | void *v; |
| 960 | // Uses sscanf instead of operator>>(istream, void*&) as a workaround |
| 961 | // for https://bugs.llvm.org/show_bug.cgi?id=19740, which presents with |
| 962 | // clang-800.0.42.1 for x86_64-apple-darwin15.6.0. |
| 963 | int result = sscanf(from.c_str(), "%p", &v); |
| 964 | if (result != 1) { |
| 965 | return false; |
| 966 | } |
| 967 | to = reinterpret_cast<T*>(v); |
| 968 | return true; |
| 969 | } |
| 970 | |
| 971 | |
| 972 | /** |