| 837 | template <typename T> |
| 838 | struct type_reflection { |
| 839 | inline static std::string name() { |
| 840 | //#if CUDA_VERSION < 8000 |
| 841 | // TODO: Use nvrtcGetTypeName once it has the same behavior as this. |
| 842 | // WAR for typeid discarding cv qualifiers on value-types |
| 843 | // Wrap type in dummy template class to preserve cv-qualifiers, then strip |
| 844 | // off the wrapper from the resulting string. |
| 845 | std::string wrapped_name = |
| 846 | demangle_native_type(typeid(JitifyTypeNameWrapper_<T>)); |
| 847 | // Note: The reflected name of this class also has namespace prefixes. |
| 848 | const std::string wrapper_class_name = "JitifyTypeNameWrapper_<"; |
| 849 | size_t start = wrapped_name.find(wrapper_class_name); |
| 850 | if (start == std::string::npos) { |
| 851 | throw std::runtime_error("Type reflection failed: " + wrapped_name); |
| 852 | } |
| 853 | start += wrapper_class_name.size(); |
| 854 | std::string name = |
| 855 | wrapped_name.substr(start, wrapped_name.size() - (start + 1)); |
| 856 | return name; |
| 857 | //#else |
| 858 | // std::string ret; |
| 859 | // nvrtcResult status = nvrtcGetTypeName<T>(&ret); |
| 860 | // if( status != NVRTC_SUCCESS ) { |
| 861 | // throw std::runtime_error(std::string("nvrtcGetTypeName |
| 862 | // failed: |
| 863 | //")+ nvrtcGetErrorString(status)); |
| 864 | // } |
| 865 | // return ret; |
| 866 | //#endif |
| 867 | } |
| 868 | }; // namespace detail |
| 869 | template <typename T, T VALUE> |
| 870 | struct type_reflection<NonType<T, VALUE> > { |
no test coverage detected