HorizontalRule.h
Go to the documentation of this file.
1 #ifndef cetlib_HorizontalRule_h
2 #define cetlib_HorizontalRule_h
3 
4 //====================================================================
5 // HorizontalRule is used by specifying the length of the rule as a
6 // c'tor argument, and then by specifying the character to be repeated
7 // as an argument to the function-call operator (e.g.):
8 //
9 // HorizontalRule r{30}; // Repeats a character 30 times
10 // std::cout << r('=') << '\n'
11 // << r('-') << '\n';
12 //
13 //====================================================================
14 
15 #include <string>
16 
17 namespace cet {
19  public:
20  explicit constexpr HorizontalRule(std::size_t const w) : w_{w} {}
21  auto
22  operator()(char const fill) const
23  {
24  return std::string(w_, fill);
25  }
26 
27  private:
28  std::size_t const w_;
29  };
30 }
31 
32 #endif /* cetlib_HorizontalRule_h */
33 
34 // Local Variables:
35 // mode: c++
36 // End:
std::string string
Definition: nybbler.cc:12
auto operator()(char const fill) const
std::size_t const w_
def fill(s)
Definition: translator.py:93
constexpr HorizontalRule(std::size_t const w)