Skip to content
Snippets Groups Projects
Commit 54a0845f authored by Jan Trávníček's avatar Jan Trávníček
Browse files

abstraction: deduplicate code in type construction

parent 5696c7c8
No related branches found
No related tags found
1 merge request!235Merge jt
......@@ -15,14 +15,7 @@ long unsigned type_util < long unsigned >::normalize ( long unsigned arg ) {
}
 
std::unique_ptr < type_details_base > type_util < long unsigned >::type ( long unsigned ) {
if constexpr ( std::is_same_v < long unsigned, size_t > ) {
core::unique_ptr_set < type_details_base > types;
types.insert ( std::make_unique < type_details_type > ( "long unsigned" ) );
types.insert ( std::make_unique < type_details_type > ( "size_t" ) );
return std::make_unique < type_details_variant_type > ( std::move ( types ) );
} else {
return std::make_unique < type_details_type > ( "long unsigned" );
}
return type_details_retriever < long unsigned >::get ( );
}
 
// ----------------------------------------------------------------------------------------------------------------
......@@ -36,7 +29,7 @@ unsigned type_util < unsigned >::normalize ( unsigned arg ) {
}
 
std::unique_ptr < type_details_base > type_util < unsigned >::type ( unsigned ) {
return std::make_unique < type_details_type > ( "unsigned" );
return type_details_retriever < unsigned >::get ( );
}
 
// ----------------------------------------------------------------------------------------------------------------
......@@ -50,7 +43,7 @@ long type_util < long >::normalize ( long arg ) {
}
 
std::unique_ptr < type_details_base > type_util < long >::type ( long ) {
return std::make_unique < type_details_type > ( "long" );
return type_details_retriever < long >::get ( );
}
 
// ----------------------------------------------------------------------------------------------------------------
......@@ -64,7 +57,7 @@ int type_util < int >::normalize ( int arg ) {
}
 
std::unique_ptr < type_details_base > type_util < int >::type ( int ) {
return std::make_unique < type_details_type > ( "int" );
return type_details_retriever < int >::get ( );
}
 
// ----------------------------------------------------------------------------------------------------------------
......@@ -78,7 +71,7 @@ char type_util < char >::normalize ( char arg ) {
}
 
std::unique_ptr < type_details_base > type_util < char >::type ( char ) {
return std::make_unique < type_details_type > ( "char" );
return type_details_retriever < char >::get ( );
}
 
// ----------------------------------------------------------------------------------------------------------------
......@@ -92,7 +85,7 @@ bool type_util < bool >::normalize ( bool arg ) {
}
 
std::unique_ptr < type_details_base > type_util < bool >::type ( bool ) {
return std::make_unique < type_details_type > ( "bool" );
return type_details_retriever < bool >::get ( );
}
 
// ----------------------------------------------------------------------------------------------------------------
......@@ -106,7 +99,7 @@ double type_util < double >::normalize ( double arg ) {
}
 
std::unique_ptr < type_details_base > type_util < double >::type ( double ) {
return std::make_unique < type_details_type > ( "double" );
return type_details_retriever < double >::get ( );
}
 
// ----------------------------------------------------------------------------------------------------------------
......@@ -120,7 +113,7 @@ std::string type_util < std::string >::normalize ( std::string arg ) {
}
 
std::unique_ptr < type_details_base > type_util < std::string >::type ( const std::string & ) {
return std::make_unique < type_details_type > ( "std::string" );
return type_details_retriever < std::string >::get ( );
}
 
// ----------------------------------------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment