TypeArguments Struct Reference

#include <datatypelib.h>

Detailed Description

TypeArguments are usually set for a DataType if it is an instantiation of a ParametricType. For example the type {Tuple<Int, Bool, String>} is an instantiation of the parametric type Tuple with the type arguments {(Int, Bool, String)}, and the type Vector is an instantiation of ParametricTypes::Vec with the type arguments {(Float, 3)}.

There are two kinds of type arguments:

  • They can be types itself (like for Tuple), these are found in args. Optionally these arguments can even specify a name together with the type. This is used e.g. for NamedTuple types like {NamedTuple<Int count, Bool valid>}.
  • They can be of integral type (like the dimension for Vec), these are found in iargs.

Public Types

using ValueType = Member
 
using ConstIterator = BaseIterator< const TypeArguments, false >
 
using IsAllocType = std::true_type
 

Public Member Functions

Block< const MemberToBlock () const
 
const Memberoperator[] (Int index) const
 
ConstIterator Begin () const
 
ConstIterator End () const
 
Int FindIndex (const Id &name) const
 
Int FindIndex (const InternedId &name) const
 
Bool operator== (const TypeArguments &other) const
 
Bool operator!= (const TypeArguments &other) const
 
HashInt GetHashCode () const
 
void RemoveReference () const
 
 ~TypeArguments ()=delete
 

Public Attributes

BaseArray< INNERMOST_MEMBERtoInnermost
 
BaseArray< Tuple< Int32, INNERMOST_MEMBER > > fromInnermost
 
BaseArray< Int64iargs
 
Int count
 
Member args [MAXON_FLEXIBLE_ARRAY_LENGTH]
 

Member Typedef Documentation

◆ ValueType

using ValueType = Member

◆ ConstIterator

using ConstIterator = BaseIterator<const TypeArguments, false>

◆ IsAllocType

using IsAllocType = std::true_type

Constructor & Destructor Documentation

◆ ~TypeArguments()

~TypeArguments ( )
delete

Member Function Documentation

◆ ToBlock()

Block<const Member> ToBlock ( ) const

Returns the type arguments which are types as a block.

◆ operator[]()

const Member& operator[] ( Int  index) const

Returns the type argument at the given index.

◆ Begin()

ConstIterator Begin ( ) const

Gets an iterator pointing to the first type argument.

Returns
Iterator for the first type argument.

◆ End()

ConstIterator End ( ) const

Returns and iterator pointing to the end of the type arguments (one behind last).

Returns
Iterator for the end of the type arguments.

◆ FindIndex() [1/2]

Int FindIndex ( const Id name) const

Searches for a named type argument which uses the given name and returns its index. If no such argument is found, -1 is returned. The function doesn't check for duplicates.

Parameters
[in]nameName to search. If this is empty, InvalidArrayIndex is returned.
Returns
Index of the matching type argument, or InvalidArrayIndex.

◆ FindIndex() [2/2]

Int FindIndex ( const InternedId name) const

Searches for a named type argument which uses the given name and returns its index. If no such argument is found, -1 is returned. The function doesn't check for duplicates.

Parameters
[in]nameName to search. If this is empty, InvalidArrayIndex is returned.
Returns
Index of the matching type argument, or InvalidArrayIndex.

◆ operator==()

Bool operator== ( const TypeArguments other) const

◆ operator!=()

Bool operator!= ( const TypeArguments other) const

◆ GetHashCode()

HashInt GetHashCode ( ) const

◆ RemoveReference()

void RemoveReference ( ) const

Member Data Documentation

◆ toInnermost

◆ fromInnermost

◆ iargs

BaseArray<Int64> iargs

The integral type arguments.

◆ count

Int count

The number of type arguments which are types.

◆ args

The type arguments which are (optionally named) types.