Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin() and End() member function with Range-based for-loop #1

Closed
redpist opened this issue Jul 3, 2011 · 1 comment
Closed

Begin() and End() member function with Range-based for-loop #1

redpist opened this issue Jul 3, 2011 · 1 comment

Comments

@redpist
Copy link
Owner

redpist commented Jul 3, 2011

At the current naming convention , we have a problem with the Range-based for-loop C++0x feature.

Explaination : this feature need a begin() and end() member functions to work but the R0x containers have Begin() and End() functions.

Solutions (or):

  1. change the naming convention.
  2. make of begin() and end() 2 exceptions
  3. other (take a look on template<T>auto begin(T& c) -> decltype(c.Begin()); )

Example of code that has to work:

#include <string>
#include <iostream>
#include "container/buffer.h"


int main(int argc, char *argv[])
{
  //test 0
  std::cout << "Test 0:" << std::endl;
  {
    std::string s0 = "I am a testing string.";
    for (char &x: s0)
      {
        std::cout << x;
      }
    std::cout << std::endl;
  }
  {
    R0x::Container::FixedBuffer<22> s0 = "I am a testing string.";
    for (char &x: s0)
      {
        std::cout << x;
      }
    std::cout << std::endl;
  }
  return 0;
}
@redpist
Copy link
Owner Author

redpist commented Jul 4, 2011

  1. make of begin() and end() 2 exceptions -> add wrapper around Begin() and End().
    You can now use begin() or Begin() and end() or End().

@redpist redpist closed this as completed Jul 4, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant