[LC++]Curiosity

Steven Shaw steven_shaw at iprimus.com.au
Wed Dec 3 16:23:01 UTC 2003


I think it's a compiler bug. I tried the following with g++-2.95 (.4) and it 
worked (all I did was remove the unneccessary cast):

#include <iostream>
#include <string>
#include <utility>

struct Dequote {
  std::string operator()(std::string token) const {
    std::string ret = "";
    ret+= token[1];
    return ret;
  }
} dequote;

int main() {
  std::pair<std::string, int>*
      lemon(new std::pair<std::string, int>("\"B\"", 99));

  std::cerr<<"\nlemon = "<<lemon->first<<"\n";

  std::string ned = dequote(lemon->first);

  std::cerr<<"\nned = "<<ned<<"\n";

  std::cerr<<"\nlemon = "<<lemon->first<<".\n";

  std::cerr<<"\nthe end.\n";
}




More information about the tuxCPProgramming mailing list