PrevUpHomeNext

utx::Delim


Object of utx::Delim is used for inserting a delim value between two values.

class Delim final;

Include

#include <utxcpp/core.hpp>

Constructors

Delim() = delete;

Delim(const std::string & a_delim_string) noexcept;

template <utx::kspt::printable PrintableValue>
Delim(const PrintableValue & delim) noexcept;

Delim(const Delim & delim) noexcept;

Public Members

inline bool operator==(const Delim & delim) const;

template <utx::kspt::printable PrintableValue>
inline bool operator==(const PrintableValue & value) const;

template <utx::kspt::ostreamable OutStream>
friend OutStream & operator<<(OutStream & os, const Delim & delim);

inline bool isNoDelim() const;

std::string data() const;

utx::NoDelim

A constant value which indicates that there should not add a delim between values.

inline const std::string && NoDelim = "utx::NoDelim";

How to insert empty delim

Empty string "", '' are not accepted by utx::Delim, which will throw an exception.

Please use utx::NoDelim, if you want to insert an empty delim.

Notice

[Note] Note
  • Accept any printable value to construct an utx::Delim object.
  • Accept any printable value to assignment operator.
  • A calling which contains utx::Delim argument accepts any printable values.
  • please use utx::NoDelim if you want an empty delim; do not use empty string such as "" or '', which will throw an exception.

Example

#include <utxcpp/core.hpp>

int main() {
	utx::print_with(utx::Delim{'-'}, "I", "have", 3, "apples");
	utx::print();
	utx::print_with('-', "I", "have", 3, "apples");
	utx::print();
/*
Result:
I-have-3-apples
I-have-3-apples
*/

	utx::print_with(777, "It", "is", "too", "small.");
	utx::print();
/*
Result:
It777is777too777small.
*/

	utx::print_with('-', 'I', "have", "no", "idea.", '\n');
/*
Result:
I-have-no-idea.-

(Because there is a delim between "idea." and '\n')
*/
}

Last revised: June 13, 2022 at 03:08:21 GMT


PrevUpHomeNext