Q:

Get all values using list iterator

I'm trying to write command line parser. Here is example of code that i used to:
#include <iostream>
#include <string>
#include <vector>
#include <list>

int main() {
    std::list<std::string> args;
    args.push_back("-l");
    args.push_back("-z");
    args.push_back("123,abc");
    args.push_back("-d");
    args.push_back("/dev/null");

    std::list<std::string>::iterator currentArgument;

    for (currentArgument = args.begin(); currentArgument != args.end();) {
        const std::string argString = *currentArgument++;
        if (argString.at(0) == '-') {
                std::cout << "key = " << argString.substr(1) << std::endl;
                std::cout << "value = " << *currentArgument << std::endl;
            } else {
                --currentArgument;
                break;
            }
        }
};

Result is:
key = l
value = -z
key = z
value = 123,abc

I tried to rewrite source code as in the example in Java:
Args.java (parseArgumentStrings method)
The problem is bool -l key, it has no value and i don't need to modify args list by adding "1" after -l or something. I can't get last key and value because argString is "123,abc" at that moment. If you look on source Java code it has hasNext() member function
So, how to rewrite this code and get output like this:
key = l
value = -z
key = z
value = 123,abc
key = d
value = /dev/null

A:

As stated in comments already, it's a bit confusing why boolean flag would have next flag as value. You did not either mention about which C++ standard/version you are using. 
I now assume your question is what's wrong with the algorithm?

Firs of all, the break statement jumps out of the for-loop (basic stuff)
without the break, it'll printout the last argument also, but it'll also stay in forever loop (since first incrementing pointer and then decrementing it) 

As stated in comments also, it would be better to check first for the '-' before 
incrementing the pointer. Note also that there exist a std::next which can be used here.
I'm not sure either that list (internally a double linked list) is best container here.
If we assume that the boolean flag should not have a value printed out, the code could look like this:
#include <iostream>
#include <string>
#include <vector>

int main() {
    std::vector<std::string> args;
    args.push_back("-l");
    args.push_back("-z");
    args.push_back("123,abc");
    args.push_back("-d");
    args.push_back("/dev/null");

    for (auto it = std::begin(args); it != std::end(args); ++it) {
        if ((*it).at(0) == '-') {
            std::cout << "key = " << (*it).substr(1) << std::endl;
            auto next = std::next(it);
            if ((*next).at(0) == '-'){
                continue;
            }else{
                std::cout << "value = " << *(++it) << std::endl;
            }
        }
    }
    return 0;
}

Of course that code does not take into account the possibility of last argument to be value only (no flag). But that's easy to implement, if needed.
I hope this helps, but I encourage you to also learn how to debug code:

debugger, has some learning curve but it is worth it
simple cout's 

