# CommutativeAssociativeBinaryOperator and const reference parameters

**URL:** <https://forums.unrealengine.com/t/commutativeassociativebinaryoperator-and-const-reference-parameters/401157>\
**Category:** Blueprint\
**Tags:** references, pins, unreal-engine, functions, Blueprint, question\
**Created:** [August 4, 2017, 11:34am UTC](https://forums.unrealengine.com/t/commutativeassociativebinaryoperator-and-const-reference-parameters/401157 "2017-08-04T11:34:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JackMorgan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JackMorgan](https://forums.unrealengine.com/u/JackMorgan)\
**Post date:** [August 4, 2017, 11:34am UTC](https://forums.unrealengine.com/t/commutativeassociativebinaryoperator-and-const-reference-parameters/401157/1 "2017-08-04T11:34:49Z")

</div>

Have been experiencing an issue where using const reference parameters in a function marked with the CommutativeAssociativeBinaryOperator metadata property declared like this

```
UFUNCTION(BlueprintPure, meta = (DisplayName = "SpecialStruct + SpecialStruct", CompactNodeTitle = "+", Keywords = "+ add plus", CommutativeAssociativeBinaryOperator = "true"), Category = "Math|Special")
	static void AddSpecialStructs(const FSpecialStruct& A, const FSpecialStruct& B, FSpecialStruct& Result);

```

has been producing the following error :

**LogOutputDevice:Error: Ensure condition failed: InputType == Pin-\>PinType [File:D:\Build++UE4+Release-4.15+Compile\Sync\Engine\Source\Editor\BlueprintGraph\Private\K2Node\_CommutativeAssociativeBinaryOperator.cpp] [Line: 128]**

This happens whenever a blueprint with this operator is opened or that operator is placed within a blueprint.

A cursory look at the differences between the pin types are the same only that the _InputType_ is const and a reference and _Pin-\>PinType_ is not. Any subsequent pins beyond the two default pins that are added using the small ‘+’ in the lower right corner of the node also appear to use the small diamond input pin style usually reserved for references.

---

<div class="post-metadata">

**Author:** ![Sn\_a\_ke](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sn\_a\_ke](https://forums.unrealengine.com/u/Sn_a_ke)\
**Post date:** [April 29, 2018, 6:34am UTC](https://forums.unrealengine.com/t/commutativeassociativebinaryoperator-and-const-reference-parameters/401157/2 "2018-04-29T06:34:00Z")

</div>

JackMorgan, did you fix it? 4.19 has the same behavior…

```
UFUNCTION(BlueprintPure, Category = "FABRIK|test", meta = (DisplayName = "AppendIntArrays", CommutativeAssociativeBinaryOperator = "true"))
static TArray<int32> BP_Append_IntArray(const TArray<int32>& A, const TArray<int32>& B)
{
	TArray<int32> out =A;
	out.Append(B);
	return out;
}

```

> [2018.04.29-06.19.57:292][355]LogBlueprintUserMessages:  
> [NewBlueprint1\_C\_0] 1.0  
> [2018.04.29-06.19.57:296][355]LogSlate: Took 0.000187 seconds to synchronously  
> load lazily loaded font  
> ‘…/…/…/Engine/Content/Slate/Fonts/Roboto-BoldCondensed.ttf’  
> (158K)  
> [2018.04.29-06.19.59:848][555]LogOutputDevice:  
> Error: Ensure condition failed:  
> InputType == Pin-\>PinType  
> [File:D:\Build++UE4+Release-4.19+Compile\Sync\Engine\Source\Editor\BlueprintGraph\Private\K2Node\_CommutativeAssociativeBinaryOperator.cpp]  
> [Line: 127]
> 
> [2018.04.29-06.19.59:848][555]LogStats: FDebug::EnsureFailed - 0.000 s  
> UE4Editor.exe has triggered a  
> breakpoint.

if you continue the work then the function works as expected

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/d/3ad09298b0af30cfc12e6201a6701052801fd3ec.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8c09e5641](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8c09e5641](https://forums.unrealengine.com/u/anonymous_user_8c09e5641)\
**Post date:** [January 16, 2019, 12:19am UTC](https://forums.unrealengine.com/t/commutativeassociativebinaryoperator-and-const-reference-parameters/401157/3 "2019-01-16T00:19:17Z")

</div>

I can confirm that this still behaves as described in 4.20; I’m seeing the same thing. K2Node\_CommutativeAssociativeBinaryOperator.cpp:127:  
ensure(InputType == Pin-\>PinType);

The Input type is the same as the pin type. However the PinType, named “ReturnValue” is non-const as it is a new value. The fault also occurs if the return pin is a value and the parameter pins are a reference:  
/\*\* Returns the maximum value of A and B \*/  
UFUNCTION(BlueprintPure, meta=(DisplayName = “Max (BigInt)”, CompactNodeTitle = “MAX”, CommutativeAssociativeBinaryOperator = “true”), Category=“Math|BigInt”)  
static const FBigInt Max(const FBigInt& A, const FBigInt& B);

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8c09e5641](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8c09e5641](https://forums.unrealengine.com/u/anonymous_user_8c09e5641)\
**Post date:** [January 16, 2019, 12:19am UTC](https://forums.unrealengine.com/t/commutativeassociativebinaryoperator-and-const-reference-parameters/401157/4 "2019-01-16T00:19:47Z")

</div>

I can confirm that this still behaves as described in 4.20; I’m seeing the same thing. K2Node\_CommutativeAssociativeBinaryOperator.cpp:127:  
ensure(InputType == Pin-\>PinType);

The Input type is the same as the pin type. However the PinType, named “ReturnValue” is non-const as it is a new value. The fault also occurs if the return pin is a value and the parameter pins are a reference:  
/\*\* Returns the maximum value of A and B \*/  
UFUNCTION(BlueprintPure, meta=(DisplayName = “Max (BigInt)”, CompactNodeTitle = “MAX”, CommutativeAssociativeBinaryOperator = “true”), Category=“Math|BigInt”)  
static const FBigInt Max(const FBigInt& A, const FBigInt& B);
