--- ini_parser.hpp 2013-02-14 14:34:30.000000000 +0100 +++ /tmp/ini_parser.hpp 2013-02-14 14:34:22.000000000 +0100 @@ -91,14 +91,19 @@ // If line is non-empty line = property_tree::detail::trim(line, stream.getloc()); + + // Ignore comments by removing them + typename std::basic_string::const_iterator first = line.begin(); + typename std::basic_string::const_iterator last = line.begin(); + while (last != line.end() && *last != semicolon && *last != hash) + ++last; + line = std::basic_string(first, last); + std::cout << line << std::endl; + if (!line.empty()) { - // Comment, section or key? - if (line[0] == semicolon || line[0] == hash) - { - // Ignore comments - } - else if (line[0] == lbracket) + // Does the line contains a key ? + if (line[0] == lbracket) { // If the previous section was empty, drop it again. if (section && section->empty())