-
-
Save artemp/45d5d82ed5696978e7c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <sstream> | |
int main(int argc,char** argv) | |
{ | |
std::ostringstream out; | |
char * str = "ABCD-"; | |
out.write(str,5); | |
out.write(str,5); | |
out.write(str,5); | |
std::cerr << out.tellp() << std::endl; | |
std::cerr << "seek 5" << std::endl; | |
out.seekp(5, std::ios::beg); | |
std::cerr << out.fail() << " " << out.good() << " " << out.eof() << std::endl ; | |
std::cerr << out.tellp() << std::endl; | |
std::cerr << "seek 15" << std::endl; | |
out.seekp(15,std::ios::beg); | |
std::cerr << out.fail() << " " << out.good() << " " << out.eof() << std::endl ; | |
std::cerr << out.tellp() << std::endl; | |
std::cerr << "seek 25" << std::endl; | |
out.seekp(25, std::ios::beg); | |
std::cerr << out.fail() << " " << out.good() << " " << out.eof() << std::endl ; | |
std::cerr << out.tellp() << std::endl; | |
std::cerr << "seek 10" << std::endl; | |
out.seekp(10, std::ios::beg); | |
std::cerr << out.fail() << " " << out.good() << " " << out.eof() << std::endl ; | |
std::cerr << out.tellp() << std::endl; | |
std::cerr << out.str() << std::endl; | |
return EXIT_SUCCESS; | |
} |
15
seek 5
0 1 0
5
seek 15
0 1 0
15
seek 25
0 1 0
15
seek 10
0 1 0
10
ABCD-ABCD-ABCD-
~/projects/mapnik8[master]$ clang++ -o seek seek.cpp -L/usr/lib -stdlib=libc++
seek.cpp:8:18: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
char * str = "ABCD-";
^
1 warning generated.
~/projects/mapnik8[master]$ otool -L seek
seek:
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
~/projects/mapnik8[master]$ ./seek
15
seek 5
0 1 0
5
seek 15
0 1 0
15
seek 25
0 1 0
15
seek 10
0 1 0
10
ABCD-ABCD-ABCD-
clang version 3.3 (179091)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get with clang++ / libstdc++: