Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    HashMap with BaseArray as value

    Cinema 4D SDK
    r19 c++
    2
    3
    508
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C4DSC
      C4DS
      last edited by

      With R20 I had no problem using a HashMap with a BaseArray<Int32> as value. All compiling fine, and working as expected.
      Porting that implementation to R19 (for users having not upgraded to R20), I encounter a compiler error, mentioning that the operator= cannot be accessed, since private.
      Obviously, I had to replace the R20 HashMap::Insert for an R19 HashMap::Put and there seems to lie the problem

      	// key is an integer and value an array of integers
      	maxon::HashMap<Int32, maxon::BaseArray<Int32>> dataKeyValue;
      
      	const Int32 key = 1;
      
      	maxon::HashMap<Int32, maxon::BaseArray<Int32>>::Entry* e = dataKeyValue.FindEntry(key);
      	if (e)
      	{
      		maxon::BaseArray<Int32>& values = e->GetValue();
      
      		// ...
      	}
      	else
      	{
      		maxon::BaseArray<Int32> newValues;
      		
      		// ...
      		
      		dataKeyValue.Put(key, newValues);
      	}
      

      The compiler error:

      error C2248: 'maxon::BaseArray<Bool,16,maxon::BASEARRAYFLAGS_0,maxon::DefaultAllocator>::operator =': cannot access private member declared in class 'maxon::BaseArray<Bool,16,maxon::BASEARRAYFLAGS_0,maxon::DefaultAllocator>'
      
      

      Any hint what I could do in order to have the same functionality compiled in R19?
      Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        Hi Daniel, thanks for reaching out us.

        With regard to your question, the old HashMap::Put implementation does only support types which have a copy-assignment operator. But there’s the FindOrCreateEntry function which inserts an entry and default-initializes the value, then the value can be set later.

        maxon::Bool created = false;
        
        maxon::HashMap<Int32, maxon::BaseArray<Int32>>::Entry* e = dataKeyValue.FindOrCreateEntry(key, created);
        
        if (!e)
                // error handling
        
        if (created)
        {
                maxon::BaseArray<Int32> newValues;
                // ...
                e->SetValue(std::move(newValues));
        }
        

        Let me know if it does work as expected.

        Cheers, Riccardo

        C4DSC 1 Reply Last reply Reply Quote 1
        • C4DSC
          C4DS @r_gigante
          last edited by C4DS

          @r_gigante
          Thanks for the headsup about FindOrCreateEntry.
          Since Put does use that method internally, I didn't even consider about trying to use it, as I simply assumed it would have the same issue. Guess I was wrong about not trying it.

          Problem solved.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post