Connect++ 0.4.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
commas::comma Class Reference

Simple function object for putting commas in lists. More...

#include <vic_strings.hpp>

Public Member Functions

 comma ()=delete
 Wouldn't make any sense.
 
 comma (size_t _target)
 Initialise with the length of the list you're printing.
 
string operator() ()
 The magic happens here!
 

Private Attributes

size_t target
 
size_t i
 

Detailed Description

Simple function object for putting commas in lists.

This avoids a load of repeated code when you have reason to output a lot of things with comma-separated lists.

Initialize the object with the actual length of the list you want to print.

Each time you call comma() you'll get a comma or an empty string with just enough commas to format the list correctly.

Definition at line 264 of file vic_strings.hpp.

Constructor & Destructor Documentation

◆ comma()

commas::comma::comma ( size_t _target)
inline

Initialise with the length of the list you're printing.

Definition at line 276 of file vic_strings.hpp.

277 : i(1), target(_target) {}

Member Function Documentation

◆ operator()()

string commas::comma::operator() ( )
inline

The magic happens here!

Definition at line 281 of file vic_strings.hpp.

281 {
282 if (i < target) {
283 i++;
284 return string(", ");
285 }
286 return string("");
287 }

Member Data Documentation

◆ i

size_t commas::comma::i
private

Definition at line 267 of file vic_strings.hpp.

◆ target

size_t commas::comma::target
private

Definition at line 266 of file vic_strings.hpp.


The documentation for this class was generated from the following file: