Skip to content

_seg_tools.h compilation error #15

@claudio-bon

Description

@claudio-bon

I am having trouble to compile the following piece of code:

ourType orderedArr[elements];
for (int ind=0; ind<elements; ind++)
{
orderedArr[ind].val=arr[ind];
orderedArr[ind].ind=ind;
}
std::qsort(orderedArr, elements, sizeof(ourType),
quickSortComp<ourType>);

elements is not known at compile time so this is a given.
The following code solved the issue:

 std::vector<ourType> orderedArr(elements); 
 for (int ind=0; ind<elements; ind++) 
 { 
     orderedArr[ind].val=arr[ind]; 
     orderedArr[ind].ind=ind; 
 } 
 std::qsort(orderedArr.data(), elements, sizeof(ourType), 
     quickSortComp<ourType>); 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions