标签:long span map 自定义 out opera nbsp log ble
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <vector> #include <map> // 用户自定义字面值,或者叫“自定义后缀”更直观些,主要作用是简化代码的读写。 long double operator"" _mm(long double x) { return x / 1000; } long double operator"" _m(long double x) { return x; } long double operator"" _km(long double x) { return x * 1000; } /* 根据 C++ 11 标准,只有下面参数列表才是合法的 char const * unsigned long long long double char const *, size_t wchar_t const *, size_t char16_t const *, size_t char32_t const *, size_t 最后四个对于字符串相当有用,因为第二个参数会自动推断为字符串的长度 */ size_t operator"" _len(char const * str, size_t size) { return size; } // 对于参数char const *,应该被称为原始字面量 raw literal 操作符. char const * operator"" _r(char const* str) { return str; } void mytest() { std::cout << 1.0_mm << std::endl; //0.001 std::cout << 1.0_m << std::endl; //1 std::cout << 1.0_km << std::endl; //1000 std::cout << "xyz"_len << std::endl; //结果为3 std::cout << 250_r << std::endl; //结果为250 return; } int main() { mytest(); system("pause"); return 0; }
标签:long span map 自定义 out opera nbsp log ble
原文地址:http://www.cnblogs.com/lsgxeva/p/7787367.html