Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-9745

Cannot create TPolyLine3D object with pointer to const

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 6.14/04
    • Fix Version/s: master
    • Component/s: Graphics
    • Labels:
      None
    • Environment:

      SL7, x86_64, C++17 standard

    • Development:

      Description

      It is not possible to create a TPolyLine3D object with a pointer-to-const object.  Presumably  the TPolyLine3D does not modify the arrays to which it refers.  If this is the case, we request that the constructors be changed to (e.g.) 'Double_t const*' instead of 'Double_t*'.  See below for an example:

       

      #include "TPolyLine3D.h"
      #include <vector>
       
      int main()
      {
        std::vector<double> const nums{1., 3.4, 7, 8., 9.34, 10.};
        auto nums_ptr = nums.data();
        auto nums_unsafe_ptr = const_cast<double*>(nums_ptr);
        TPolyLine3D pl1{static_cast<int>(nums.size()), nums_ptr}; // Compilation fails
        TPolyLine3D pl2{static_cast<int>(nums.size()), nums_unsafe_ptr}; // Compilation successful
      }

        Attachments

          Activity

            People

            • Assignee:
              couet Olivier Couet
              Reporter:
              8ad121ca011a999be580 Kyle Knoepfel
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: