Skip to content

CppSharp is generating a three parameter equality operator #1251

Closed
@HarryDC

Description

@HarryDC
Brief Description

Just started working with cppsharp so I apologize if i missed some setup. I am trying to wrap a smaller c++ codebase and on my first tries cppsharp is generating an equality operator that takes three parameters (which fails compilation), the Internal call that gets executed also has three parameters (incorrectly), the class wrapped is an a simple implementation of std::optional. This happens for currently to template types, std::string and uint, and also for the inqueality operator !=.
The call to __Internal.OperatorEqualEqual(__arg0, __arg0, __arg2); also fails compilation as this function only has two parameters.

Thanks in advance for any help on this.

OS: Windows

Used headers

exception, type_traits (directly from the included file)

Used settings
options.GenerateClassTemplates = true;
options.GenerateDebugOutput = true;

Target: MSVC

Other settings

C++ partial source
template <class T>
class Optional
{
public:
        ...
	inline bool operator==(const Optional<T>& rhs) const
	{
		return (m_hasValue == rhs.m_hasValue && (!m_hasValue || m_value == rhs.m_value));
	}
	inline bool operator==(const T& rhs) const
	{
		return (m_hasValue && m_value == rhs);
	}
       ...
}
Stack trace or incompilable generated code
// DEBUG: inline bool operator==(const T& rhs) const
public static bool operator ==(this global::Msta.Msta.Runtime.Optional<string> @this, global::Msta.Msta.Runtime.Optional<string> __op, string rhs)
{
    bool @thisNull = ReferenceEquals(@this, null);
    bool __opNull = ReferenceEquals(__op, null);
    if (@thisNull || __opNull)
        return @thisNull && __opNull;
    var __arg0 = @this.__Instance;
    var __arg1 = __op.__Instance;
    var __basicString2 = new global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>>();
    global::Std.BasicStringExtensions.Assign(__basicString2, rhs);
    var __arg2 = __basicString2.__Instance;
    var __ret = __Internal.OperatorEqualEqual(__arg0, __arg0, __arg2);
    __basicString2.Dispose();
    return __ret;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions