eswitch-v5
Advanced counterpart for switch statement in C++
Modules

Description

Classes

struct  eswitch_v5::regexter
 

Functions

static auto eswitch_v5::operator== (const std::string &tuple_entry, const regexter &value)
 CaseModule to support for matching and withdrawing of values for and from regular expression. More...
 
template<typename TupleEntry , typename UnderlyingType >
static constexpr auto eswitch_v5::operator== (TupleEntry &&tuple_entry, const is< UnderlyingType > &) noexcept
 CaseModule to support for matching for various polymorphic types. More...
 

Function Documentation

◆ operator==() [1/2]

static auto eswitch_v5::operator== ( const std::string tuple_entry,
const regexter value 
)
static

#include <eswitch_v5.hpp>

CaseModule to support for matching and withdrawing of values for and from regular expression.

Definition at line 413 of file eswitch_v5.hpp.

414  {
415  if( std::smatch match; std::regex_match( tuple_entry, match, value.value ) )
416  {
418  vs.reserve( match.size() );
419 
420  for( const auto & v : match )
421  vs.push_back( v );
422 
423  return std::make_optional( std::move( vs ) );
424  }
425 
427  }

◆ operator==() [2/2]

template<typename TupleEntry , typename UnderlyingType >
static constexpr auto eswitch_v5::operator== ( TupleEntry &&  tuple_entry,
const is< UnderlyingType > &   
)
staticconstexprnoexcept

#include <eswitch_v5.hpp>

CaseModule to support for matching for various polymorphic types.

CaseModule to support for matching and withdrawing of values from std::any.

Definition at line 432 of file eswitch_v5.hpp.

433  {
435 
437  const UnderlyingType, UnderlyingType >;
438 
439  if constexpr( std::is_pointer_v< _T > )
440  {
441  auto * d = dynamic_cast< type* >( tuple_entry );
442 
443  return d != nullptr ? std::make_optional( d ) : std::optional< type* >{};
444  }
445  else
446  {
447  try
448  {
449  auto & d = dynamic_cast< type& >( tuple_entry );
450  return std::make_optional( std::ref( d ) );
451  }
452  catch( const std::bad_cast & )
453  {
455  }
456  }
457  }
std::vector::reserve
T reserve(T... args)
std::vector
STL class.
std::make_optional
T make_optional(T... args)
std::regex_match
T regex_match(T... args)
std::bad_cast
STL class.
std::vector::push_back
T push_back(T... args)
std::remove_reference_t
std
STL namespace.
std::optional
std::smatch
std::conditional_t
std::ref
T ref(T... args)