User-defined literal --C ++ 11 (ten)

 
No. head File Namespace Literals Explanation
1 <chrono> std::literals::chrono_literals h, min, s, ms, us, ns 123s seconds
2 <string> std::literals::string_literals s "Abc" s is a std :: string
3 <string_view> std::literals::string_literals en  
4 <complex> std::literals::complex_literals i, the, ow 12.7i imaginary part, 1 + 2i is a complex number
Complex constexpr < Double > operator "" I ( Long  Double Arg)   // literal definition of the imaginary part 
{
     return { 0 , Arg}; 
} 
Complex < Double > Z = 2.7 + 2 .3i;

 

Guess you like

Origin www.cnblogs.com/share-ideas/p/11886787.html