Author Topic: auto  (Read 446 times)

jcfuller

  • Sr. Member
  • ****
  • Posts: 268
    • View Profile
auto
« on: May 26, 2020, 02:25:14 PM »
Kevin,
  In the Bcx_Revisions.txt file you note that "AUTO" and "REGISTER" may be removed or altered in the future. I am wishing that the future is soon for an altered auto?

auto should be c++ only
auto dbl = 1.5
Allow:
Code: [Select]
    Raw As vector<string> s = {"one","two","three","four","five"}
    cout << "s contains" << endl
    xFor auto it = s.begin() While it <> s.end() By ++it
        cout << " " << *it
    xNext
    cout << endl
   
Translate to:
Code: [Select]
    for(auto it = s.begin(); it != s.end(); ++it)
    {
        cout << " " << *it;
    }

    cout << endl;
   
Another wish is for a range based for loop discussed in the below link. I am not versed at all on most of the variations. The one I use is for iterating primarily c++ STL vectors.
Code: [Select]
'range based for loop
    B$ = "three"
    cout << "range-based for loop" << endl
    RbFor ( auto it : s)
        If it = B$ Then
            cout << "B$ match" << endl
            A$ = it.c_str()
            break
        End If
        cout << " " << it << endl
    Next
Translated to
Code: [Select]
    strcpy(B, "three");
    cout << "range-based for loop" << endl;
    for ( auto it : s)
    {
        if(it == B )
        {
            cout << "B$ match" << endl;
            strcpy(A, it.c_str());
            break;
        }
        cout << " " << it << endl;
    }


Here is an informative  link.
https://www.acodersjourney.com/c-11-auto/


James