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 & a_delim) noexcept;

delim(const delim & a_delim) noexcept;

Public Members

inline bool operator==(const delim & a_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 & a_delim);

inline bool is_no_delim() const;

std::string data() const;

utx::no_delim

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

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

How to insert empty delim

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

Please use utx::no_delim, 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::no_delim 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: November 24, 2022 at 11:26:05 GMT


PrevUpHomeNext