I declare a variable like this :
TMap<int32, TDoubleLinkedList<int32>> newMap;
And call Add or Emplace function like this :
newMap.Add(1);
or
newMap.Add(1, TDoubleLinkedList<int32>());
But error occurred.
Is there any solution that use TMap with TDoubleLinkedList?
Below is error log.
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(51): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'TTuple<KeyType,ValueType>'
with
[
KeyType=int32,
ValueType=TDoubleLinkedList<int32>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(51): note: No constructor could take the source type, or constructor overload resolution was ambiguous
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Set.h(207): note: see reference to function template instantiation 'TPairInitializer<InitKeyType &&,InitValueType &&>::operator TTuple<KeyType,ValueType>(void) const<KeyType,ValueType>' being compiled
with
[
InitKeyType=int,
InitValueType=TDoubleLinkedList<int32>,
KeyType=int32,
ValueType=TDoubleLinkedList<int32>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Set.h(206): note: see reference to function template instantiation 'TPairInitializer<InitKeyType &&,InitValueType &&>::operator TTuple<KeyType,ValueType>(void) const<KeyType,ValueType>' being compiled
with
[
InitKeyType=int,
InitValueType=TDoubleLinkedList<int32>,
KeyType=int32,
ValueType=TDoubleLinkedList<int32>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Set.h(242): note: see reference to function template instantiation 'TSetElementBase<InElementType,true>::TSetElementBase<T,void>(InitType &&)' being compiled
with
[
InElementType=TTuple<int32,TDoubleLinkedList<int32>>,
T=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>,
InitType=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Set.h(241): note: see reference to function template instantiation 'TSetElementBase<InElementType,true>::TSetElementBase<T,void>(InitType &&)' being compiled
with
[
InElementType=TTuple<int32,TDoubleLinkedList<int32>>,
T=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>,
InitType=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Set.h(717): note: see reference to function template instantiation 'TSetElement<InElementType>::TSetElement<T,void>(InitType &&)' being compiled
with
[
InElementType=TTuple<int32,TDoubleLinkedList<int32>>,
T=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>,
InitType=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Set.h(717): note: see reference to function template instantiation 'TSetElement<InElementType>::TSetElement<T,void>(InitType &&)' being compiled
with
[
InElementType=TTuple<int32,TDoubleLinkedList<int32>>,
T=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>,
InitType=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(404): note: see reference to function template instantiation 'FSetElementId TSet<TTuple<KeyType,ValueType>,KeyFuncs,SetAllocator>::Emplace<TPairInitializer<InitKeyType &&,InitValueType &&>>(ArgsType &&,bool *)' being compiled
with
[
KeyType=int32,
ValueType=TDoubleLinkedList<int32>,
KeyFuncs=TDefaultMapHashableKeyFuncs<int32,TDoubleLinkedList<int32>,false>,
SetAllocator=FDefaultSetAllocator,
InitKeyType=int,
InitValueType=TDoubleLinkedList<int32>,
ArgsType=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(404): note: see reference to function template instantiation 'FSetElementId TSet<TTuple<KeyType,ValueType>,KeyFuncs,SetAllocator>::Emplace<TPairInitializer<InitKeyType &&,InitValueType &&>>(ArgsType &&,bool *)' being compiled
with
[
KeyType=int32,
ValueType=TDoubleLinkedList<int32>,
KeyFuncs=TDefaultMapHashableKeyFuncs<int32,TDoubleLinkedList<int32>,false>,
SetAllocator=FDefaultSetAllocator,
InitKeyType=int,
InitValueType=TDoubleLinkedList<int32>,
ArgsType=TPairInitializer<int &&,TDoubleLinkedList<int32> &&>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(365): note: see reference to function template instantiation 'ValueType &TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>::Emplace<int,TDoubleLinkedList<int32>>(InitKeyType &&,InitValueType &&)' being compiled
with
[
ValueType=TDoubleLinkedList<int32>,
KeyType=int32,
SetAllocator=FDefaultSetAllocator,
KeyFuncs=TDefaultMapHashableKeyFuncs<int32,TDoubleLinkedList<int32>,false>,
InitKeyType=int,
InitValueType=TDoubleLinkedList<int32>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(365): note: see reference to function template instantiation 'ValueType &TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>::Emplace<int,TDoubleLinkedList<int32>>(InitKeyType &&,InitValueType &&)' being compiled
with
[
ValueType=TDoubleLinkedList<int32>,
KeyType=int32,
SetAllocator=FDefaultSetAllocator,
KeyFuncs=TDefaultMapHashableKeyFuncs<int32,TDoubleLinkedList<int32>,false>,
InitKeyType=int,
InitValueType=TDoubleLinkedList<int32>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(365): note: while compiling class template member function 'ValueType &TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>::Add(KeyType &&,ValueType &&)'
with
[
ValueType=TDoubleLinkedList<int32>,
KeyType=int32,
SetAllocator=FDefaultSetAllocator,
KeyFuncs=TDefaultMapHashableKeyFuncs<int32,TDoubleLinkedList<int32>,false>
]
[The line and path of Add function called in my project]: note: see reference to function template instantiation 'ValueType &TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>::Add(KeyType &&,ValueType &&)' being compiled
with
[
ValueType=TDoubleLinkedList<int32>,
KeyType=int32,
SetAllocator=FDefaultSetAllocator,
KeyFuncs=TDefaultMapHashableKeyFuncs<int32,TDoubleLinkedList<int32>,false>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(966): note: see reference to class template instantiation 'TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs>' being compiled
with
[
KeyType=int32,
ValueType=TDoubleLinkedList<int32>,
SetAllocator=FDefaultSetAllocator,
KeyFuncs=TDefaultMapHashableKeyFuncs<int32,TDoubleLinkedList<int32>,false>
]
D:\Program Files\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Map.h(1102): note: see reference to class template instantiation 'TSortableMapBase<InKeyType,InValueType,SetAllocator,KeyFuncs>' being compiled
with
[
InKeyType=int32,
InValueType=TDoubleLinkedList<int32>,
SetAllocator=FDefaultSetAllocator,
KeyFuncs=TDefaultMapHashableKeyFuncs<int32,TDoubleLinkedList<int32>,false>
]
[The line and path of Add function called in my project]: note: see reference to class template instantiation 'TMap<int32,TDoubleLinkedList<int32>,FDefaultSetAllocator,TDefaultMapHashableKeyFuncs<InKeyType,InValueType,false>>' being compiled
with
[
InKeyType=int32,
InValueType=TDoubleLinkedList<int32>
]
Build failed.
Thank you for your help ![]()
+) I try to wrap TDoubleLinkedList by struct or class. But results are the same.
struct FListWrapper
{
TDoubleLinkedList<int32> list;
}