dimanche 8 mars 2015

Huge program size C++ with std::regex

I want to compile small C++ program with std::regex (standart regular expression library). Compiler - gcc/g++ 4.9.2 on Fedora 21.



#include <string.h>
#include <iostream>
#include <regex>
using namespace std;
int main () {
cout << "Content-Type: text/html\n\n";
std::string s ("there is a subsequence in the string\n");
std::regex e ("\\b(sub)([^ ]*)"); // matches words beginning by "sub"
std::cout << std::regex_replace (s,e,"sub-$2");
}


It's not possible to compile program with std::regex without -std=c++11, so suitable instruction for compiling in terminal:



g++ -std=c++11 code.cpp -o prog


Main question: source code very small, but why the final file size of compiled program such a huge - 480 kilobytes?


Is it influence of -std=c++11?


What happened and how is it possible to reduce the size of the final binary program?


Sorry for my English, I'm not native speaker.


Aucun commentaire:

Enregistrer un commentaire