Speclib  0.1.2
The library for writing better CUDA libraries
sp::c::String< Char, Log2MaxSize > Class Template Referencefinal

Like std::string, but for compile-time use. More...

#include <String.hpp>

Public Member Functions

constexpr String (char c)
 
constexpr String (const char *other)
 
constexpr String (int n)
 Format an integer as a string in base-10. More...
 
constexpr bool operator== (const String &rhs) const
 
constexpr bool operator!= (const String &rhs) const
 
constexpr Stringoperator+= (const String &rhs)
 
constexpr String operator+ (const String &rhs) const
 
constexpr void truncate (int n)
 Delete n characters from the end. More...
 
constexpr Stringoperator<< (const String &rhs)
 Stream-like operator to append to the string. More...
 
constexpr Char & operator[] (int i)
 
constexpr const Char & operator[] (int i) const
 
constexpr bool empty () const
 
constexpr int size () const
 

Detailed Description

template<typename Char = char, int Log2MaxSize = 31>
class sp::c::String< Char, Log2MaxSize >

Like std::string, but for compile-time use.

Note
Like all structures in the sp::c namespace, this cannot be used at runtime.
Template Parameters
CharThe character type. The default is char. Must be default constexpr constructible and constexpr copyable or a fundamental data type.
Log2MaxSizeThe maximum size of the string expressed as a log base 2. The default is 31 (enough for about 2 billion characters). The maximum size of the string is 2^Log2MaxSize - 1. This template parameter is useful to limit the address space used by the container (e.g: to nest containers).

Constructor & Destructor Documentation

◆ String()

template<typename Char = char, int Log2MaxSize = 31>
constexpr sp::c::String< Char, Log2MaxSize >::String ( int  n)
constexpr

Format an integer as a string in base-10.

Member Function Documentation

◆ operator<<()

template<typename Char = char, int Log2MaxSize = 31>
constexpr String & sp::c::String< Char, Log2MaxSize >::operator<< ( const String< Char, Log2MaxSize > &  rhs)
constexpr

Stream-like operator to append to the string.

This is useful for building strings by concatenation.

◆ truncate()

template<typename Char = char, int Log2MaxSize = 31>
constexpr void sp::c::String< Char, Log2MaxSize >::truncate ( int  n)
constexpr

Delete n characters from the end.