arsenalgear-cpp
A library containing general purpose C++ utils.
operators.hpp
Go to the documentation of this file.
1 //====================================================
2 // File data
3 //====================================================
11 //====================================================
12 // Preprocessor settings
13 //====================================================
14 #pragma once
15 #ifndef ARSENALGEAR_OPERATORS_HPP
16 #define ARSENALGEAR_OPERATORS_HPP
17 
18 //====================================================
19 // Headers
20 //====================================================
21 
22 // STD headers
23 #include <string>
24 
25 //====================================================
26 // String operators
27 //====================================================
28 
29 // std::string * int
37 template <typename T>
38 inline std::string operator *( const T& generic_string, unsigned int integer )
39  {
40  std::string output;
41  output.reserve( integer * generic_string.size() );
42 
43  while( integer -- )
44  {
45  output += generic_string;
46  }
47 
48  return output;
49  }
50 
51 // int * std::string
59 #if ! _MSC_VER
60 template <typename T>
61 inline std::string operator *( unsigned int integer, const T& generic_string )
62  {
63  return generic_string * integer;
64  }
65 #endif
66 
67 #endif
std::string operator*(const T &generic_string, unsigned int integer)
Function to multiply a string by an integer.
Definition: operators.hpp:38