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

    BaseArray

    SDK Help
    0
    14
    1.2k
    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.
    • H
      Helper
      last edited by

      On 02/04/2014 at 13:27, xxxxxxxx wrote:

      What errors?

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 03/04/2014 at 08:25, xxxxxxxx wrote:

        This the error message:

        1>d:\program files\maxon\cinema 4d r15 beta\plugins\simple test c++ plugin\basearray_test.cpp(34) : error C2664: 'maxon::BaseArray<T>::Swap' : cannot convert parameter 1 from 'int' to 'maxon::BaseArray<T>::IteratorTemplate<CONSTITERATOR>'
        1>          with
        1>          [
        1>              T=String
        1>          ]
        1>          No constructor could take the source type, or constructor overload resolution was ambiguous

        This the line of code that gives the error:
        Line 34: myBaseArray.Swap(2, eb); //swap elements

        I'm using VS c++ 2010 Express

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 03/04/2014 at 17:17, xxxxxxxx wrote:

          You may need to cast and/or type your values as ConstIterator instead of Int.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 07/04/2014 at 01:01, xxxxxxxx wrote:

            Sorry, I tried a sorts of typecasts, but I did not succeed.
            It keeps telling me Error: identifier "ConstIterator" is unidentified .

            Could you please give me an example.

            Pim

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 07/04/2014 at 08:34, xxxxxxxx wrote:

              Is Swap() not supposed to used like this ?

                
              myBaseArray.Swap(myBaseArray[2], myBaseArray[1]);  
              
              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 08/04/2014 at 01:56, xxxxxxxx wrote:

                I read the manual as that you have to supply two indexes in basearray.
                But I think you are right. I give it a try.

                Thanks, Pim

                _<_div ="memproto" style="font-weight: bold; font-size: 14px; line-height: 22px; font-family: roboto, sans-serif; border-top-width: 1px; border-top-style: solid; border-top-color: rgb150, 170, 209; border-left-width: 1px; border-left-style: solid; border-left-color: rgb150, 170, 209; border-right-width: 1px; border-right-style: solid; border-right-color: rgb150, 170, 209; padding: 6px 0px; color: rgb26, 37, 59; text-shadow: rgba255, 255, 255, 0.901961 0px 1px 1px; -: http://kinug.com/c4d/cpp/help/pages/c4d_miscav_f.png; : rgb220, 226, 239; -shadow: rgba0, 0, 0, 0.14902 5px 5px 5px; -webkit--shadow: rgba0, 0, 0, 0.14902 5px 5px 5px; border-top-right-radius: 4px; border-top-left-radius: 4px; -repeat: repeat no-repeat;"_>_void Swap ( Iterator a,
                Iterator b
                ) inline_>

                _<_div ="memdoc" style="font-size: 14px; line-height: 22px; font-family: roboto, sans-serif; border-width: 0px 1px 1px; border-bottom-style: solid; border-bottom-color: rgb150, 170, 209; border-left-style: solid; border-left-color: rgb150, 170, 209; border-right-style: solid; border-right-color: rgb150, 170, 209; padding: 6px 10px 2px; -: http://kinug.com/c4d/cpp/help/pages/c4d_miscav_g.png; -shadow: rgba0, 0, 0, 0.14902 5px 5px 5px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; -webkit--shadow: rgba0, 0, 0, 0.14902 5px 5px 5px; -repeat: repeat no-repeat;"_>_epeat no-repeat;">
                Swaps elements a and b (equivalent to global Swap(array[a], array **)
                Parameters
                [in]| a| Position of element to be swapped.

                [in] b Position of elemen_<_t_>_ be swapped.
                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 09/04/2014 at 03:03, xxxxxxxx wrote:

                  Have you tried something like this?

                  arr.Swap(arr.Begin() + 2, arr.Begin() + 1)
                  
                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 09/04/2014 at 07:53, xxxxxxxx wrote:

                    This is working:

                    myBaseArray.Swap(myBaseArray.Begin() + 2, myBaseArray.Begin() + 1)
                    

                    This is NOT working:

                    myBaseArray.Swap(myBaseArray[2], myBaseArray[1]);
                    
                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 09/04/2014 at 15:35, xxxxxxxx wrote:

                      Very strange since the documentation shows the NOT working way as an example.  Maybe we can get some resolution on what is valid and what is not?

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 10/04/2014 at 01:50, xxxxxxxx wrote:

                        Yes, indeed strange. Hopefully someone can check / explain.
                        But for now, I have a solution.

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          On 10/04/2014 at 03:59, xxxxxxxx wrote:

                          Originally posted by xxxxxxxx

                          Very strange since the documentation shows the NOT working way as an example.  Maybe we can get some resolution on what is valid and what is not?

                          Could you point me to the link where the BaseArray documentation shows a wrong example?

                          The documentation states that you need an iterator for the position and just using an Int or passing the content of a specific array position (like the OP did in his examples) of course doesn't magically create an iterator (just imagine the swap function would have expected a String as input parameter for the position, then just passing an Int wouldn't work either).

                          You have to pass the expected parameter type - and Niklas showed how to do it properly.

                          Best regards,

                          Wilfried

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            On 10/04/2014 at 18:17, xxxxxxxx wrote:

                            Not a direct example, but it somewhat draws one in the wrong direction if you have no idea about BaseArray::Swap() :

                            Swaps elements a and b (equivalent to global Swap(array[a], array[b]))
                            

                            **
                            **
                            **
                            **


                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              On 11/04/2014 at 07:07, xxxxxxxx wrote:

                              Reading that, I immediately think of Swap looking like this:

                              template <typename T>
                              void Swap(T& a, T& b) {
                                  T c = a;
                                  a = b;
                                  b = c;
                              }
                              

                              Would be of no advantage to define it as a member method if it is declared and implemented 
                              like this. I agree, though, that the documentation could elaborate more on swapping.

                              Best,
                              -Niklas

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