#ifndef OPT_HPP_ #define OPT_HPP_ #include "symbol.hpp" template< class Symbol > class opt : public symbol { public: template< class CharType > constexpr opt( const_string< CharType > str , std::size_t begin = 0 ) : symbol ( begin == invalid_index ? invalid_index : Symbol( str , begin ).valid() ? Symbol( str , begin ).end() : begin ) , m_str( str ) , m_begin( begin ) { } constexpr Symbol get() { return Symbol( m_str , m_begin ); } constexpr operator bool() { return Symbol( m_str , m_begin ).valid(); } private: const_string< char > m_str; const std::size_t m_begin; }; #endif