MCPcopy Create free account
hub / github.com/davisking/dlib / lpad

Function lpad

dlib/string/string.h:728–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

726 typename alloc
727 >
728 const std::basic_string<charT,traits,alloc> lpad (
729 const std::basic_string<charT,traits,alloc>& str,
730 long pad_length,
731 const std::basic_string<charT,traits,alloc>& pad_string
732 )
733 {
734 typedef std::basic_string<charT,traits,alloc> string;
735 // if str is too big then just return str
736 if (pad_length <= static_cast<long>(str.size()))
737 return str;
738
739 // make the string we will padd onto the string
740 string P;
741 while (P.size() < pad_length - str.size())
742 P += pad_string;
743 P = P.substr(0,pad_length - str.size());
744
745 // return the padded string
746 return P + str;
747 }
748
749 template <
750 typename charT,

Callers 2

string_testFunction · 0.85
padFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by 1

string_testFunction · 0.68