From 031b18fe686f716fe7b032634235ccf79b0f00e1 Mon Sep 17 00:00:00 2001 From: richelbilderbeek Date: Sat, 3 Mar 2018 13:51:05 +0100 Subject: [PATCH] Cleanup, fix dead links --- content/CppConst.md | 2 +- content/CppConstCorrect.md | 46 +- content/CppDoubleToStr.md | 2 +- content/CppGlobal.md | 2 +- content/CppHelgrindExample3.md | 607 +++++++++---- ...rrorEoUint_maxWasNotDeclaredInThisScope.md | 820 +++++++++++++----- content/CppLocalVersusGlobal.md | 46 +- content/CppMatrix.md | 388 ++------- content/CppQtCreatorProFile.md | 142 +-- content/CppQtQuadBezierArrowItem.md | 136 +-- content/CppScope.md | 52 +- content/CppState.md | 48 +- content/CppStk.md | 212 +---- content/CppToDouble.md | 2 +- content/CppUnits.md | 547 +----------- content/CppUnsigned.md | 47 +- 16 files changed, 1221 insertions(+), 1878 deletions(-) diff --git a/content/CppConst.md b/content/CppConst.md index a8b94917..f23ac003 100644 --- a/content/CppConst.md +++ b/content/CppConst.md @@ -56,7 +56,7 @@ In [class design](CppClassDesign.md) consider using: * [6] [Herb Sutter](CppHerbSutter.md), [Andrei Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 15: 'Use const proactively'. * [7] [Herb Sutter](CppHerbSutter.md). Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Be const correct'. * [8] [Marshall Cline](CppMarshallCline.md), [Greg Lomow](CppGregLomow.md) and [Mike Girou](CppMikeGirou.md). C++ FAQs. ISBN: 0-201-3098301. FAQ 14.05: 'Is const correctness tedious?' (Answer: no). - * [9] [The C++ FAQ Lite](http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.1). Item 18.1: What is 'const correctness' (Answer: 'A good thing')? + * [9] [The C++ FAQ Lite](https://isocpp.org/wiki/faq/const-correctness#overview-const). Item 18.1: What is 'const correctness' (Answer: 'A good thing')? * [10] [Bruce Eckel](CppBruceEckel.md). Thinking in C++, second edition, volume 1. 2000. ISBN: 0-13-979809-9. Item 8: 'Constants', paragraph 'Summary': 'const-correctness can be a lifesaver for projects'. * [11] [John Lakos](CppJohnLakos.md). Large-Scale C++ Software Design. 1996. ISBN: 0-201-63362-0. Chapter 2.3.3 * [12] [John Lakos](CppJohnLakos.md). Large-Scale C++ Software Design. 1996. ISBN: 0-201-63362-0. Chapter 9.1.6: 'Every object in a system should be const-correct' diff --git a/content/CppConstCorrect.md b/content/CppConstCorrect.md index 3b942f07..1ccd85ea 100644 --- a/content/CppConstCorrect.md +++ b/content/CppConstCorrect.md @@ -11,38 +11,14 @@ correct](CppConstCorrect.md) \[7-11\]. ## [References](CppReferences.md) -1. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (3rd edition). ISBN: 0-201-88954-4 7.9.3: 'Use const - extensively and consistently'. -2. [Scott Meyers](CppScottMeyers.md). Effective C++ (3rd - edition).ISBN: 0-321-33487-6. Item 3: 'Use const whenever possible'. -3. [Jarrod Hollingworth](CppJarrodHollingworth.md), [Bob - Swart](CppBobSwart.md), [Mark Cashman](CppMarkCashman.md), [Paul - Gustavson](CppPaulGustavson.md). Sams C++ Builder 6 - Developer's Guide. ISBN: 0-672-32480-6. Chapter 3: 'Understand and - use const in your code'. -4. [Jesse Liberty](CppJesseLiberty.md). Sams teach yourself C++ in - 24 hours. ISBN: 0-672-32224-2. Hour 8, chapter 'Const member - functions': 'Use const whenever possible.'. -5. [Scott Meyers](CppScottMeyers.md). Effective C++ (3rd edition). - ISBN: 0-321-33487-6. Item 2: 'Prefer consts, enums and inlines - to \#defines'. -6. [Herb Sutter](CppHerbSutter.md), [Andrei - Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 - rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 15: - 'Use const proactively'. -7. [Herb Sutter](CppHerbSutter.md). Exceptional C++ style. 2005. - ISBN: 0-201-76042-8. Item 1 guideline: 'Be const correct'. -8. [Marshall Cline](CppMarshallCline.md), [Greg - Lomow](CppGregLomow.md) and [Mike Girou](CppMikeGirou.md). - C++ FAQs. ISBN: 0-201-3098301. FAQ 14.05: 'Is const correctness - tedious?' (Answer: no). -9. [The C++ FAQ - Lite](http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.1). - Item 18.1: What is 'const correctness' (Answer: 'A good thing')? -10. [Bruce Eckel](CppBruceEckel.md). Thinking in C++, second edition, - volume 1. 2000. ISBN: 0-13-979809-9. Item 8: 'Constants', paragraph - 'Summary': 'const-correctness can be a lifesaver for projects'. -11. [John Lakos](CppJohnLakos.md). Large-Scale C++ Software Design. - 1996. ISBN: 0-201-63362-0. Chapter 9.1.6: 'Every object in a system - should be const-correct' +1. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (3rd edition). ISBN: 0-201-88954-4 7.9.3: 'Use const extensively and consistently'. +2. [Scott Meyers](CppScottMeyers.md). Effective C++ (3rd edition).ISBN: 0-321-33487-6. Item 3: 'Use const whenever possible'. +3. [Jarrod Hollingworth](CppJarrodHollingworth.md), [Bob Swart](CppBobSwart.md), [Mark Cashman](CppMarkCashman.md), [Paul Gustavson](CppPaulGustavson.md). Sams C++ Builder 6 Developer's Guide. ISBN: 0-672-32480-6. Chapter 3: 'Understand and use const in your code'. +4. [Jesse Liberty](CppJesseLiberty.md). Sams teach yourself C++ in 24 hours. ISBN: 0-672-32224-2. Hour 8, chapter 'Const member functions': 'Use const whenever possible.'. +5. [Scott Meyers](CppScottMeyers.md). Effective C++ (3rd edition). ISBN: 0-321-33487-6. Item 2: 'Prefer consts, enums and inlines to \#defines'. +6. [Herb Sutter](CppHerbSutter.md), [Andrei Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 15: 'Use const proactively'. +7. [Herb Sutter](CppHerbSutter.md). Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Be const correct'. +8. [Marshall Cline](CppMarshallCline.md), [Greg Lomow](CppGregLomow.md) and [Mike Girou](CppMikeGirou.md). C++ FAQs. ISBN: 0-201-3098301. FAQ 14.05: 'Is const correctness tedious?' (Answer: no). +9. [The C++ FAQ Lite](https://isocpp.org/wiki/faq/const-correctness#overview-const). Item 18.1: What is 'const correctness' (Answer: 'A good thing')? +10. [Bruce Eckel](CppBruceEckel.md). Thinking in C++, second edition, volume 1. 2000. ISBN: 0-13-979809-9. Item 8: 'Constants', paragraph 'Summary': 'const-correctness can be a lifesaver for projects'. +11. [John Lakos](CppJohnLakos.md). Large-Scale C++ Software Design. 1996. ISBN: 0-201-63362-0. Chapter 9.1.6: 'Every object in a system should be const-correct' diff --git a/content/CppDoubleToStr.md b/content/CppDoubleToStr.md index 3e1b2a96..3fd3a0c1 100644 --- a/content/CppDoubleToStr.md +++ b/content/CppDoubleToStr.md @@ -117,7 +117,7 @@ External links   - [C++ FAQ lite page about double to std::string - conversion](http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.1) + conversion](https://isocpp.org/wiki/faq/misc-technical-issues#convert-num-to-string)   diff --git a/content/CppGlobal.md b/content/CppGlobal.md index 09b909c5..a78ff8ca 100644 --- a/content/CppGlobal.md +++ b/content/CppGlobal.md @@ -19,7 +19,7 @@ visible in its [scope](CppScope.md)). A non-[const](CppConst.md) * [1] [Andrei Alexandrescu](CppAndreiAlexandrescu.md). Modern C++ Design. 2001. ISBN: 0201704315. Item 10: 'Minimize global and shared data'. * [2] Stephen C. Dewhurst. C++ Gotchas. 2003. ISBN: 0-321-12518-5. Gotcha #3: 'Avoid global variables'. - * [3] [C++ FAQ Lite](http://www.parashift.com/c++-faq/global-vars.html): 'The names of global variables should start with //' and 'Instead of using a global variable, you should seriously consider if there are ways to limit the variable's visibility and/or lifetime'. + * [3] [C++ FAQ Lite](https://isocpp.org/wiki/faq/coding-standards#global-vars): 'The names of global variables should start with //' and 'Instead of using a global variable, you should seriously consider if there are ways to limit the variable's visibility and/or lifetime'. * [4] [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (3rd edition).ISBN: 0-201-88954-4. Chapter 1.8.2.a: 'Don't use global data (use members)' * [5] [Jarrod Hollingworth](CppJarrodHollingworth.md) , Bob Swart, Mark Cashman, Paul Gustavson. Sams C++ Builder 6 Developer's Guide. ISBN: 0-672-32480-6. Chapter 3: 'Avoid using global variables' * [6] [Jesse Liberty](CppJesseLiberty.md) . Sams teach yourself C++ in 24 hours. ISBN: 0-672-32224-2. Hour 5, paragraph 'Global variables': 'In C++, global variables are avoided because they can create very confusing code that is hard to maintain.' diff --git a/content/CppHelgrindExample3.md b/content/CppHelgrindExample3.md index 048d70e3..21c391d6 100644 --- a/content/CppHelgrindExample3.md +++ b/content/CppHelgrindExample3.md @@ -1,193 +1,450 @@ - -  - -  - -  - -  - -  - -([C++](Cpp.md)) ![Wt](PicWt.png)![Qt Creator](PicQtCreator.png)![Lubuntu](PicLubuntu.png)![Web](PicWeb.png) [helgrind example 3: Hello Wt](CppHelgrindExample3.md) -==================================================================================================================================================================== - -  +# ([C++](Cpp.md)) ![Wt](PicWt.png)![Qt Creator](PicQtCreator.png)![Lubuntu](PicLubuntu.png)![Web](PicWeb.png) [helgrind example 3: Hello Wt](CppHelgrindExample3.md) This [helgrind](CppHelgrind.md) example tests a slightly adapted version of ['Hello Wt' using Qt Creator under Ubuntu](CppHelloWtQtCreatorUbuntu.md) for possible problems. -  - - [Download the Qt Creator project 'CppHelgrindExample3' (zip)](CppHelgrindExample3.md) -  - The original version was adapted to let the program quit. So, I added a [Wt::WPushButton](CppWPushButton.md) that calls [std::exit](CppStdExit.md). -  - -  - -  - -  - -  - -Technical facts ---------------- - -  - -[Application type(s)](CppApplication.md) - -- ![Web](PicWeb.png) [Web application](CppWebApplication.md) - -[Operating system(s) or programming environment(s)](CppOs.md) - -- ![Lubuntu](PicLubuntu.png) [Lubuntu](CppLubuntu.md) 11.04 (natty) - -[IDE(s)](CppIde.md): - -- ![Qt Creator](PicQtCreator.png) [Qt Creator](CppQtCreator.md) 2.0.1 - -[Project type](CppQtProjectType.md): - -- ![console](PicConsole.png) [Console - application](CppConsoleApplication.md) - -[C++ standard](CppStandard.md): - -- ![C++98](PicCpp98.png) [C++98](Cpp98.md) - -[Compiler(s)](CppCompiler.md): - -- [G++](CppGpp.md) 4.5.2 - -[Libraries](CppLibrary.md) used: - -- ![Boost](PicBoost.png) [Boost](CppBoost.md): version 1.42 -- ![STL](PicStl.png) [STL](CppStl.md): GNU ISO C++ Library, version - 4.5.2 -- ![Wt](PicWt.png) [Wt](CppWt.md): version 3.1.9 - -  - -  - -  - -  - -  - -[Qt project file](CppQtProjectFile.md): CppHelgrindExample3.pro ----------------------------------------------------------------- - -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #------------------------------------------------- # # Project created by QtCreator 2010-11-18T12:10:20 # #------------------------------------------------- QT       += core QT       -= gui TARGET = CppHelgrindExample3 LIBS += -lwt -lwthttp CONFIG   += console CONFIG   -= app_bundle TEMPLATE = app SOURCES += main.cpp` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -main.cpp --------- - -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` /* * Copyright 2008 Emweb bvba, Heverlee, Belgium. * * See the LICENSE file for terms of use. */ #include #include #include #include #include #include #include using namespace Wt; /* * A simple hello world application class which demonstrates how to react * to events, read input, and give feed-back. */ class HelloApplication : public WApplication { public:   HelloApplication(const WEnvironment& env); private:   WLineEdit *nameEdit_;   WText *greeting_;   void greet();   void quit(); //Added by RJCB }; /* * The env argument contains information about the new session, and * the initial request. It must be passed to the WApplication * constructor so it is typically also an argument for your custom * application constructor. */ HelloApplication::HelloApplication(const WEnvironment& env)   : WApplication(env) {   setTitle("Hello world");                               // application title   root()->addWidget(new WText("Your name, please ? "));  // show some text   nameEdit_ = new WLineEdit(root());                     // allow text input   nameEdit_->setFocus();                                 // give focus   WPushButton *b = new WPushButton("Greet me.", root()); // create a button   b->setMargin(5, Left);                                 // add 5 pixels margin   root()->addWidget(new WBreak());                       // insert a line break   greeting_ = new WText(root());                         // empty text   root()->addWidget(new WBreak());                         // RJCB   WPushButton * const q = new WPushButton("Quit", root()); // RJCB   q->clicked().connect(this, &HelloApplication::quit);     // RJCB   /*    * Connect signals with slots    *    * - simple Wt-way    */   b->clicked().connect(this, &HelloApplication::greet);   /*    * - using an arbitrary function object (binding values with boost::bind())    */   nameEdit_->enterPressed().connect     (boost::bind(&HelloApplication::greet, this)); } void HelloApplication::greet() {   /*    * Update the text, using text input into the nameEdit_ field.    */   greeting_->setText("Hello there, " + nameEdit_->text()); } //Method added by RJCB void HelloApplication::quit() {   std::exit(0); } WApplication *createApplication(const WEnvironment& env) {   /*    * You could read information from the environment to decide whether    * the user has permission to start a new application    */   return new HelloApplication(env); } int main(int argc, char **argv) {   /*    * Your main method may set up some shared resources, but should then    * start the server application (FastCGI or httpd) that starts listening    * for requests, and handles all of the application life cycles.    *    * The last argument to WRun specifies the function that will instantiate    * new application objects. That function is executed when a new user surfs    * to the Wt application, and after the library has negotiated browser    * support. The function should return a newly instantiated application    * object.    */   return WRun(argc, argv, &createApplication); }` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -helgrind.sh ------------ - -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ` #!/bin/sh valgrind --tool=helgrind --log-file=helgrind.txt ../CppHelgrindExample3-build-desktop/./CppHelgrindExample3 --docroot=. --http-address=0.0.0.0 --http-port=8080` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - -  - -  - -  - -  - -  - -memcheck.sh ------------ -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #!/bin/sh valgrind --leak-check=full -v --show-reachable=yes --log-file=memcheck.txt ../CppHelgrindExample3-build-desktop/./CppHelgrindExample3 --docroot=. --http-address=0.0.0.0 --http-port=8080 ` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -helgrind.txt ------------- - -  +## main.cpp + +```c++ +/* +* Copyright (C) 2008 Emweb bvba, Heverlee, Belgium. +* +* See the LICENSE file for terms of use. +*/ + +#include +#include +#include +#include +#include +#include + +#include + +using namespace Wt; + +/* +* A simple hello world application class which demonstrates how to react +* to events, read input, and give feed-back. +*/ +class HelloApplication : public WApplication +{ +public: + HelloApplication(const WEnvironment& env); + +private: + WLineEdit *nameEdit_; + WText *greeting_; + + void greet(); + void quit(); //Added by RJCB +}; + +/* +* The env argument contains information about the new session, and +* the initial request. It must be passed to the WApplication +* constructor so it is typically also an argument for your custom +* application constructor. +*/ +HelloApplication::HelloApplication(const WEnvironment& env) + : WApplication(env) +{ + setTitle("Hello world"); // application title + + root()->addWidget(new WText("Your name, please ? ")); // show some text + nameEdit_ = new WLineEdit(root()); // allow text input + nameEdit_->setFocus(); // give focus + + WPushButton *b = new WPushButton("Greet me.", root()); // create a button + b->setMargin(5, Left); // add 5 pixels margin + + root()->addWidget(new WBreak()); // insert a line break + + greeting_ = new WText(root()); // empty text + + + root()->addWidget(new WBreak()); // RJCB + WPushButton * const q = new WPushButton("Quit", root()); // RJCB + q->clicked().connect(this, &HelloApplication::quit); // RJCB + + /* + * Connect signals with slots + * + * - simple Wt-way + */ + b->clicked().connect(this, &HelloApplication::greet); + + /* + * - using an arbitrary function object (binding values with boost::bind()) + */ + nameEdit_->enterPressed().connect + (boost::bind(&HelloApplication::greet, this)); +} + +void HelloApplication::greet() +{ + /* + * Update the text, using text input into the nameEdit_ field. + */ + greeting_->setText("Hello there, " + nameEdit_->text()); +} + +//Method added by RJCB +void HelloApplication::quit() +{ + std::exit(0); +} + +WApplication *createApplication(const WEnvironment& env) +{ + /* + * You could read information from the environment to decide whether + * the user has permission to start a new application + */ + return new HelloApplication(env); +} + +int main(int argc, char **argv) +{ + /* + * Your main method may set up some shared resources, but should then + * start the server application (FastCGI or httpd) that starts listening + * for requests, and handles all of the application life cycles. + * + * The last argument to WRun specifies the function that will instantiate + * new application objects. That function is executed when a new user surfs + * to the Wt application, and after the library has negotiated browser + * support. The function should return a newly instantiated application + * object. + */ + return WRun(argc, argv, &createApplication); +} +```  + +## helgrind.sh + +``` +#!/bin/sh +valgrind --tool=helgrind --log-file=helgrind.txt ../CppHelgrindExample3-build-desktop/./CppHelgrindExample3 --docroot=. --http-address=0.0.0.0 --http-port=8080 +```  + +## memcheck.sh + +``` +#!/bin/sh +valgrind --leak-check=full -v --show-reachable=yes --log-file=memcheck.txt ../CppHelgrindExample3-build-desktop/./CppHelgrindExample3 --docroot=. --http-address=0.0.0.0 --http-port=8080 +```  + +## helgrind.txt helgrind.txt is the output file created by [helgrind](CppHelgrind.md): - -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` ==17884== Helgrind, a thread error detector ==17884== Copyright 2007-2010, and GNU GPL'd, by OpenWorks LLP et al. ==17884== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info ==17884== Command: ../CppHelgrindExample3-build-desktop/./CppHelgrindExample3 --docroot=. --http-address=0.0.0.0 --http-port=8080 ==17884== Parent PID: 17883 ==17884== ==17884== Thread #3 was created ==17884==    at 0x4A9A728: clone (clone.S:111) ==17884==    by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) ==17884==    by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) ==17884==    by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) ==17884==    by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) ==17884==    by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) ==17884==    by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) ==17884==    by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) ==17884== ==17884== Thread #2 was created ==17884==    at 0x4A9A728: clone (clone.S:111) ==17884==    by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) ==17884==    by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) ==17884==    by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) ==17884==    by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) ==17884==    by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) ==17884==    by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) ==17884==    by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) ==17884== ==17884== Possible data race during read of size 4 at 0x4b5318c by thread #3 ==17884==    at 0x4B48E44: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:49) ==17884==    by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) ==17884==    by 0x4B4901D: thread_proxy (thread.cpp:117) ==17884==    by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) ==17884==    by 0x4888E98: start_thread (pthread_create.c:304) ==17884==    by 0x4A9A73D: clone (clone.S:130) ==17884==  This conflicts with a previous write of size 4 by thread #2 ==17884==    at 0x4B48F3D: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:72) ==17884==    by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) ==17884==    by 0x4B4901D: thread_proxy (thread.cpp:117) ==17884==    by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) ==17884==    by 0x4888E98: start_thread (pthread_create.c:304) ==17884==    by 0x4A9A73D: clone (clone.S:130) ==17884== ==17884== Possible data race during read of size 4 at 0x4b53188 by thread #3 ==17884==    at 0x4B48E4A: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:49) ==17884==    by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) ==17884==    by 0x4B4901D: thread_proxy (thread.cpp:117) ==17884==    by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) ==17884==    by 0x4888E98: start_thread (pthread_create.c:304) ==17884==    by 0x4A9A73D: clone (clone.S:130) ==17884==  This conflicts with a previous write of size 4 by thread #2 ==17884==    at 0x4B48F43: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:72) ==17884==    by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) ==17884==    by 0x4B4901D: thread_proxy (thread.cpp:117) ==17884==    by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) ==17884==    by 0x4888E98: start_thread (pthread_create.c:304) ==17884==    by 0x4A9A73D: clone (clone.S:130) ==17884== ==17884== Possible data race during read of size 4 at 0x4b531f4 by thread #3 ==17884==    at 0x4B4E85F: boost::detail::get_once_per_thread_epoch() (once.cpp:40) ==17884==    by 0x4B48E54: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:50) ==17884==    by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) ==17884==    by 0x4B4901D: thread_proxy (thread.cpp:117) ==17884==    by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) ==17884==    by 0x4888E98: start_thread (pthread_create.c:304) ==17884==    by 0x4A9A73D: clone (clone.S:130) ==17884==  This conflicts with a previous write of size 4 by thread #2 ==17884==    at 0x488E34D: pthread_key_create (pthread_key_create.c:44) ==17884==    by 0x4B4E7F9: create_epoch_tss_key (once.cpp:32) ==17884==    by 0x488E99F: pthread_once (pthread_once.S:122) ==17884==    by 0x4B48E54: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:50) ==17884==    by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) ==17884==    by 0x4B4901D: thread_proxy (thread.cpp:117) ==17884==    by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) ==17884==    by 0x4888E98: start_thread (pthread_create.c:304) ==17884== ==17884== Thread #9 was created ==17884==    at 0x4A9A728: clone (clone.S:111) ==17884==    by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) ==17884==    by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) ==17884==    by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) ==17884==    by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) ==17884==    by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) ==17884==    by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) ==17884==    by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) ==17884== ==17884== Possible data race during write of size 4 at 0x613f638 by thread #9 ==17884==    at 0x43B9069: Wt::WebSession::setState(Wt::WebSession::State, int) (WebSession.C:222) ==17884==    by 0x43B914E: Wt::WebSession::setLoaded() (WebSession.C:209) ==17884==    by 0x43C0994: Wt::WebSession::handleRequest(Wt::WebSession::Handler&) (WebSession.C:1214) ==17884==    by 0x43D86A3: Wt::WebController::handleAsyncRequest(Wt::WebRequest*) (WebController.C:638) ==17884==    by 0x43D9703: Wt::WebController::handleRequest(Wt::WebRequest*) (WebController.C:512) ==17884==    by 0x45BE959: Wt::WServer::handleRequest(Wt::WebRequest*) (WServer.C:372) ==17884==    by 0x45C690D: http::server::WtReply::consumeRequestBody(char const*, char const*, http::server::Request::State) (WtReply.C:187) ==17884==    by 0x45C7CDB: http::server::WtReply::consumeData(char const*, char const*, http::server::Request::State) (WtReply.C:81) ==17884==    by 0x45889DF: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:137) ==17884==    by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) ==17884==    by 0x4571A8B: http::server::Connection::handleReadRequest0() (Connection.C:120) ==17884==    by 0x4571C89: http::server::Connection::handleReadRequest(boost::system::error_code const&, unsigned int) (Connection.C:154) ==17884==  This conflicts with a previous read of size 4 by thread #2 ==17884==    at 0x43D85BD: Wt::WebController::handleAsyncRequest(Wt::WebRequest*) (WebController.C:590) ==17884==    by 0x43D9703: Wt::WebController::handleRequest(Wt::WebRequest*) (WebController.C:512) ==17884==    by 0x45BE959: Wt::WServer::handleRequest(Wt::WebRequest*) (WServer.C:372) ==17884==    by 0x45C690D: http::server::WtReply::consumeRequestBody(char const*, char const*, http::server::Request::State) (WtReply.C:187) ==17884==    by 0x45C7CDB: http::server::WtReply::consumeData(char const*, char const*, http::server::Request::State) (WtReply.C:81) ==17884==    by 0x45889DF: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:137) ==17884==    by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) ==17884==    by 0x4571A8B: http::server::Connection::handleReadRequest0() (Connection.C:120) ==17884==  Address 0x613f638 is 144 bytes inside a block of size 1472 alloc'd ==17884==    at 0x402647D: operator new(unsigned int) (vg_replace_malloc.c:255) ==17884==    by 0x43D89ED: Wt::WebController::handleAsyncRequest(Wt::WebRequest*) (WebController.C:613) ==17884==    by 0x43D9703: Wt::WebController::handleRequest(Wt::WebRequest*) (WebController.C:512) ==17884==    by 0x45BE959: Wt::WServer::handleRequest(Wt::WebRequest*) (WServer.C:372) ==17884==    by 0x45C690D: http::server::WtReply::consumeRequestBody(char const*, char const*, http::server::Request::State) (WtReply.C:187) ==17884==    by 0x45C7CDB: http::server::WtReply::consumeData(char const*, char const*, http::server::Request::State) (WtReply.C:81) ==17884==    by 0x45889DF: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:137) ==17884==    by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) ==17884==    by 0x4571A8B: http::server::Connection::handleReadRequest0() (Connection.C:120) ==17884==    by 0x4571C89: http::server::Connection::handleReadRequest(boost::system::error_code const&, unsigned int) (Connection.C:154) ==17884==    by 0x45B6071: boost::asio::detail::handler_queue::handler_wrapper, boost::_bi::list3 >, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (mem_fn_template.hpp:271) ==17884==    by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) ==17884== ==17884== Possible data race during write of size 4 at 0x614c8f0 by thread #2 ==17884==    at 0x4928DFE: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x45C64D7: http::server::WtReply::nextContentBuffer() (basic_string.h:787) ==17884==    by 0x457F722: http::server::Reply::encodeNextContentBuffer(std::vector >&, int&, int&) (Reply.C:527) ==17884==    by 0x4580BD1: http::server::Reply::nextBuffers(std::vector >&) (Reply.C:369) ==17884==    by 0x45713FA: http::server::Connection::startWriteResponse() (Connection.C:201) ==17884==    by 0x457123F: http::server::Connection::handleWriteResponse() (Connection.C:225) ==17884==    by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) ==17884==    by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) ==17884==    by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) ==17884==    by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) ==17884==    by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) ==17884==    by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) ==17884==  This conflicts with a previous read of size 4 by thread #9 ==17884==    at 0x4927D5E: std::string::swap(std::string&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x45C64EF: http::server::WtReply::nextContentBuffer() (WtReply.C:329) ==17884==    by 0x457F722: http::server::Reply::encodeNextContentBuffer(std::vector >&, int&, int&) (Reply.C:527) ==17884==    by 0x4580BD1: http::server::Reply::nextBuffers(std::vector >&) (Reply.C:369) ==17884==    by 0x45713FA: http::server::Connection::startWriteResponse() (Connection.C:201) ==17884==    by 0x457123F: http::server::Connection::handleWriteResponse() (Connection.C:225) ==17884==    by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) ==17884==    by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) ==17884==  Address 0x614c8f0 is 8 bytes inside a block of size 65 alloc'd ==17884==    at 0x402647D: operator new(unsigned int) (vg_replace_malloc.c:255) ==17884==    by 0x49289F7: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x4169873: char* std::string::_S_construct(char*, char*, std::allocator const&, std::forward_iterator_tag) (basic_string.tcc:138) ==17884==    by 0x457D674: http::server::HTTPRequest::flush(Wt::WebRequest::ResponseState, boost::function) (basic_string.h:1649) ==17884==    by 0x43C041E: Wt::WebSession::handleRequest(Wt::WebSession::Handler&) (WebSession.C:1254) ==17884==    by 0x43D86A3: Wt::WebController::handleAsyncRequest(Wt::WebRequest*) (WebController.C:638) ==17884==    by 0x43D9703: Wt::WebController::handleRequest(Wt::WebRequest*) (WebController.C:512) ==17884==    by 0x45BE959: Wt::WServer::handleRequest(Wt::WebRequest*) (WServer.C:372) ==17884==    by 0x45C690D: http::server::WtReply::consumeRequestBody(char const*, char const*, http::server::Request::State) (WtReply.C:187) ==17884==    by 0x45C7CDB: http::server::WtReply::consumeData(char const*, char const*, http::server::Request::State) (WtReply.C:81) ==17884==    by 0x45889DF: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:137) ==17884==    by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) ==17884== ==17884== Thread #10 was created ==17884==    at 0x4A9A728: clone (clone.S:111) ==17884==    by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) ==17884==    by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) ==17884==    by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) ==17884==    by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) ==17884==    by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) ==17884==    by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) ==17884==    by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) ==17884== ==17884== Possible data race during write of size 4 at 0x49816f0 by thread #2 ==17884==    at 0x48EF2B9: std::locale::locale(std::locale::_Impl*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x48F1505: std::locale::classic() (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x42679FB: std::basic_string, std::allocator > boost::posix_time::to_simple_string_type(boost::posix_time::ptime) (date_formatting.hpp:85) ==17884==    by 0x4266507: Wt::WLogEntry::operator<<(Wt::WLogger::TimeStamp const&) (time_formatters.hpp:184) ==17884==    by 0x457F35E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:469) ==17884==    by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) ==17884==    by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) ==17884==    by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) ==17884==    by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) ==17884==    by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) ==17884==    by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) ==17884==    by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) ==17884==  This conflicts with a previous write of size 4 by thread #10 ==17884==    at 0x48EF2B9: std::locale::locale(std::locale::_Impl*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x48F1505: std::locale::classic() (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x42679FB: std::basic_string, std::allocator > boost::posix_time::to_simple_string_type(boost::posix_time::ptime) (date_formatting.hpp:85) ==17884==    by 0x4266507: Wt::WLogEntry::operator<<(Wt::WLogger::TimeStamp const&) (time_formatters.hpp:184) ==17884==    by 0x43B8DC0: Wt::WebSession::log(std::string const&) const (WebSession.C:131) ==17884==    by 0x43C3CB1: Wt::WebSession::~WebSession() (WebSession.C:171) ==17884==    by 0x436F078: boost::detail::sp_counted_impl_p::dispose() (checked_delete.hpp:34) ==17884==    by 0x804B8F7: boost::detail::shared_count::~shared_count() (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) ==17884== ==17884== Possible data race during write of size 4 at 0x6144d40 by thread #2 ==17884==    at 0x45C5106: http::server::WtReply::~WtReply() (WtReply.C:63) ==17884==    by 0x45C56B1: http::server::WtReply::~WtReply() (WtReply.C:72) ==17884==    by 0x4587AE7: boost::detail::sp_counted_impl_p::dispose() (checked_delete.hpp:34) ==17884==    by 0x804B8F7: boost::detail::shared_count::~shared_count() (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) ==17884==    by 0x4571179: http::server::Connection::handleWriteResponse() (shared_ptr.hpp:169) ==17884==    by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) ==17884==    by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) ==17884==    by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) ==17884==    by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) ==17884==    by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) ==17884==    by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) ==17884==    by 0x45C4041: boost::detail::thread_data, boost::_bi::list2, boost::_bi::value > > >::run() (mem_fn_template.hpp:165) ==17884==  This conflicts with a previous read of size 4 by thread #10 ==17884==    at 0x45889ED: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:139) ==17884==    by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) ==17884==    by 0x4571A8B: http::server::Connection::handleReadRequest0() (Connection.C:120) ==17884==    by 0x4571C89: http::server::Connection::handleReadRequest(boost::system::error_code const&, unsigned int) (Connection.C:154) ==17884==    by 0x45B6071: boost::asio::detail::handler_queue::handler_wrapper, boost::_bi::list3 >, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (mem_fn_template.hpp:271) ==17884==    by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) ==17884==    by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) ==17884==    by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) ==17884==  Address 0x6144d40 is 0 bytes inside a block of size 476 alloc'd ==17884==    at 0x402647D: operator new(unsigned int) (vg_replace_malloc.c:255) ==17884==    by 0x4586C67: http::server::RequestHandler::handleRequest(http::server::Request&) (RequestHandler.C:145) ==17884==    by 0x45719FB: http::server::Connection::handleReadRequest0() (Connection.C:116) ==17884==    by 0x4571C89: http::server::Connection::handleReadRequest(boost::system::error_code const&, unsigned int) (Connection.C:154) ==17884==    by 0x45B6071: boost::asio::detail::handler_queue::handler_wrapper, boost::_bi::list3 >, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (mem_fn_template.hpp:271) ==17884==    by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) ==17884==    by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) ==17884==    by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) ==17884==    by 0x45C4041: boost::detail::thread_data, boost::_bi::list2, boost::_bi::value > > >::run() (mem_fn_template.hpp:165) ==17884==    by 0x4B49028: thread_proxy (thread.cpp:120) ==17884==    by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) ==17884==    by 0x4888E98: start_thread (pthread_create.c:304) ==17884== ==17884== Thread #8 was created ==17884==    at 0x4A9A728: clone (clone.S:111) ==17884==    by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) ==17884==    by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) ==17884==    by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) ==17884==    by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) ==17884==    by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) ==17884==    by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) ==17884==    by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) ==17884== ==17884== Thread #11 was created ==17884==    at 0x4A9A728: clone (clone.S:111) ==17884==    by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) ==17884==    by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) ==17884==    by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) ==17884==    by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) ==17884==    by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) ==17884==    by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) ==17884==    by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) ==17884== ==17884== Possible data race during read of size 4 at 0x497fe8c by thread #8 ==17884==    at 0x491C438: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x4265C7A: Wt::WLogger::addLine(std::string const&) const (basic_string.h:2605) ==17884==    by 0x426621F: Wt::WLogEntry::~WLogEntry() (WLogger.C:27) ==17884==    by 0x457F49E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:464) ==17884==    by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) ==17884==    by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) ==17884==    by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) ==17884==    by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) ==17884==    by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) ==17884==    by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) ==17884==    by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) ==17884==    by 0x45C4041: boost::detail::thread_data, boost::_bi::list2, boost::_bi::value > > >::run() (mem_fn_template.hpp:165) ==17884==  This conflicts with a previous write of size 4 by thread #11 ==17884==    at 0x491C53C: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x4265C7A: Wt::WLogger::addLine(std::string const&) const (basic_string.h:2605) ==17884==    by 0x426621F: Wt::WLogEntry::~WLogEntry() (WLogger.C:27) ==17884==    by 0x457F49E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:464) ==17884==    by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) ==17884==    by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) ==17884==    by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) ==17884==    by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) ==17884== ==17884== Possible data race during write of size 4 at 0x497fe8c by thread #8 ==17884==    at 0x491C53C: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x4265C7A: Wt::WLogger::addLine(std::string const&) const (basic_string.h:2605) ==17884==    by 0x426621F: Wt::WLogEntry::~WLogEntry() (WLogger.C:27) ==17884==    by 0x457F49E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:464) ==17884==    by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) ==17884==    by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) ==17884==    by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) ==17884==    by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) ==17884==    by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) ==17884==    by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) ==17884==    by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) ==17884==    by 0x45C4041: boost::detail::thread_data, boost::_bi::list2, boost::_bi::value > > >::run() (mem_fn_template.hpp:165) ==17884==  This conflicts with a previous write of size 4 by thread #11 ==17884==    at 0x491C53C: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) ==17884==    by 0x4265C7A: Wt::WLogger::addLine(std::string const&) const (basic_string.h:2605) ==17884==    by 0x426621F: Wt::WLogEntry::~WLogEntry() (WLogger.C:27) ==17884==    by 0x457F49E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:464) ==17884==    by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) ==17884==    by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) ==17884==    by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) ==17884==    by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) ==17884== ==17884== ==17884== For counts of detected and suppressed errors, rerun with: -v ==17884== Use --history-level=approx or =none to gain increased speed, at ==17884== the cost of reduced accuracy of conflicting-access information ==17884== ERROR SUMMARY: 35 errors from 9 contexts (suppressed: 9621 from 566)` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -   +``` +==17884== Helgrind, a thread error detector +==17884== Copyright (C) 2007-2010, and GNU GPL'd, by OpenWorks LLP et al. +==17884== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info +==17884== Command: ../CppHelgrindExample3-build-desktop/./CppHelgrindExample3 --docroot=. --http-address=0.0.0.0 --http-port=8080 +==17884== Parent PID: 17883 +==17884== +==17884== Thread #3 was created +==17884== at 0x4A9A728: clone (clone.S:111) +==17884== by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) +==17884== by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) +==17884== by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) +==17884== by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) +==17884== by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) +==17884== by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) +==17884== by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) +==17884== +==17884== Thread #2 was created +==17884== at 0x4A9A728: clone (clone.S:111) +==17884== by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) +==17884== by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) +==17884== by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) +==17884== by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) +==17884== by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) +==17884== by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) +==17884== by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) +==17884== +==17884== Possible data race during read of size 4 at 0x4b5318c by thread #3 +==17884== at 0x4B48E44: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:49) +==17884== by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) +==17884== by 0x4B4901D: thread_proxy (thread.cpp:117) +==17884== by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) +==17884== by 0x4888E98: start_thread (pthread_create.c:304) +==17884== by 0x4A9A73D: clone (clone.S:130) +==17884== This conflicts with a previous write of size 4 by thread #2 +==17884== at 0x4B48F3D: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:72) +==17884== by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) +==17884== by 0x4B4901D: thread_proxy (thread.cpp:117) +==17884== by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) +==17884== by 0x4888E98: start_thread (pthread_create.c:304) +==17884== by 0x4A9A73D: clone (clone.S:130) +==17884== +==17884== Possible data race during read of size 4 at 0x4b53188 by thread #3 +==17884== at 0x4B48E4A: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:49) +==17884== by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) +==17884== by 0x4B4901D: thread_proxy (thread.cpp:117) +==17884== by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) +==17884== by 0x4888E98: start_thread (pthread_create.c:304) +==17884== by 0x4A9A73D: clone (clone.S:130) +==17884== This conflicts with a previous write of size 4 by thread #2 +==17884== at 0x4B48F43: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:72) +==17884== by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) +==17884== by 0x4B4901D: thread_proxy (thread.cpp:117) +==17884== by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) +==17884== by 0x4888E98: start_thread (pthread_create.c:304) +==17884== by 0x4A9A73D: clone (clone.S:130) +==17884== +==17884== Possible data race during read of size 4 at 0x4b531f4 by thread #3 +==17884== at 0x4B4E85F: boost::detail::get_once_per_thread_epoch() (once.cpp:40) +==17884== by 0x4B48E54: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:50) +==17884== by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) +==17884== by 0x4B4901D: thread_proxy (thread.cpp:117) +==17884== by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) +==17884== by 0x4888E98: start_thread (pthread_create.c:304) +==17884== by 0x4A9A73D: clone (clone.S:130) +==17884== This conflicts with a previous write of size 4 by thread #2 +==17884== at 0x488E34D: pthread_key_create (pthread_key_create.c:44) +==17884== by 0x4B4E7F9: create_epoch_tss_key (once.cpp:32) +==17884== by 0x488E99F: pthread_once (pthread_once.S:122) +==17884== by 0x4B48E54: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.clone.101 (once.hpp:50) +==17884== by 0x4B48F96: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:104) +==17884== by 0x4B4901D: thread_proxy (thread.cpp:117) +==17884== by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) +==17884== by 0x4888E98: start_thread (pthread_create.c:304) +==17884== +==17884== Thread #9 was created +==17884== at 0x4A9A728: clone (clone.S:111) +==17884== by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) +==17884== by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) +==17884== by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) +==17884== by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) +==17884== by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) +==17884== by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) +==17884== by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) +==17884== +==17884== Possible data race during write of size 4 at 0x613f638 by thread #9 +==17884== at 0x43B9069: Wt::WebSession::setState(Wt::WebSession::State, int) (WebSession.C:222) +==17884== by 0x43B914E: Wt::WebSession::setLoaded() (WebSession.C:209) +==17884== by 0x43C0994: Wt::WebSession::handleRequest(Wt::WebSession::Handler&) (WebSession.C:1214) +==17884== by 0x43D86A3: Wt::WebController::handleAsyncRequest(Wt::WebRequest*) (WebController.C:638) +==17884== by 0x43D9703: Wt::WebController::handleRequest(Wt::WebRequest*) (WebController.C:512) +==17884== by 0x45BE959: Wt::WServer::handleRequest(Wt::WebRequest*) (WServer.C:372) +==17884== by 0x45C690D: http::server::WtReply::consumeRequestBody(char const*, char const*, http::server::Request::State) (WtReply.C:187) +==17884== by 0x45C7CDB: http::server::WtReply::consumeData(char const*, char const*, http::server::Request::State) (WtReply.C:81) +==17884== by 0x45889DF: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:137) +==17884== by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) +==17884== by 0x4571A8B: http::server::Connection::handleReadRequest0() (Connection.C:120) +==17884== by 0x4571C89: http::server::Connection::handleReadRequest(boost::system::error_code const&, unsigned int) (Connection.C:154) +==17884== This conflicts with a previous read of size 4 by thread #2 +==17884== at 0x43D85BD: Wt::WebController::handleAsyncRequest(Wt::WebRequest*) (WebController.C:590) +==17884== by 0x43D9703: Wt::WebController::handleRequest(Wt::WebRequest*) (WebController.C:512) +==17884== by 0x45BE959: Wt::WServer::handleRequest(Wt::WebRequest*) (WServer.C:372) +==17884== by 0x45C690D: http::server::WtReply::consumeRequestBody(char const*, char const*, http::server::Request::State) (WtReply.C:187) +==17884== by 0x45C7CDB: http::server::WtReply::consumeData(char const*, char const*, http::server::Request::State) (WtReply.C:81) +==17884== by 0x45889DF: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:137) +==17884== by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) +==17884== by 0x4571A8B: http::server::Connection::handleReadRequest0() (Connection.C:120) +==17884== Address 0x613f638 is 144 bytes inside a block of size 1472 alloc'd +==17884== at 0x402647D: operator new(unsigned int) (vg_replace_malloc.c:255) +==17884== by 0x43D89ED: Wt::WebController::handleAsyncRequest(Wt::WebRequest*) (WebController.C:613) +==17884== by 0x43D9703: Wt::WebController::handleRequest(Wt::WebRequest*) (WebController.C:512) +==17884== by 0x45BE959: Wt::WServer::handleRequest(Wt::WebRequest*) (WServer.C:372) +==17884== by 0x45C690D: http::server::WtReply::consumeRequestBody(char const*, char const*, http::server::Request::State) (WtReply.C:187) +==17884== by 0x45C7CDB: http::server::WtReply::consumeData(char const*, char const*, http::server::Request::State) (WtReply.C:81) +==17884== by 0x45889DF: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:137) +==17884== by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) +==17884== by 0x4571A8B: http::server::Connection::handleReadRequest0() (Connection.C:120) +==17884== by 0x4571C89: http::server::Connection::handleReadRequest(boost::system::error_code const&, unsigned int) (Connection.C:154) +==17884== by 0x45B6071: boost::asio::detail::handler_queue::handler_wrapper, boost::_bi::list3 >, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (mem_fn_template.hpp:271) +==17884== by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) +==17884== +==17884== Possible data race during write of size 4 at 0x614c8f0 by thread #2 +==17884== at 0x4928DFE: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x45C64D7: http::server::WtReply::nextContentBuffer() (basic_string.h:787) +==17884== by 0x457F722: http::server::Reply::encodeNextContentBuffer(std::vector >&, int&, int&) (Reply.C:527) +==17884== by 0x4580BD1: http::server::Reply::nextBuffers(std::vector >&) (Reply.C:369) +==17884== by 0x45713FA: http::server::Connection::startWriteResponse() (Connection.C:201) +==17884== by 0x457123F: http::server::Connection::handleWriteResponse() (Connection.C:225) +==17884== by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) +==17884== by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) +==17884== by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) +==17884== by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) +==17884== by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) +==17884== by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) +==17884== This conflicts with a previous read of size 4 by thread #9 +==17884== at 0x4927D5E: std::string::swap(std::string&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x45C64EF: http::server::WtReply::nextContentBuffer() (WtReply.C:329) +==17884== by 0x457F722: http::server::Reply::encodeNextContentBuffer(std::vector >&, int&, int&) (Reply.C:527) +==17884== by 0x4580BD1: http::server::Reply::nextBuffers(std::vector >&) (Reply.C:369) +==17884== by 0x45713FA: http::server::Connection::startWriteResponse() (Connection.C:201) +==17884== by 0x457123F: http::server::Connection::handleWriteResponse() (Connection.C:225) +==17884== by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) +==17884== by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) +==17884== Address 0x614c8f0 is 8 bytes inside a block of size 65 alloc'd +==17884== at 0x402647D: operator new(unsigned int) (vg_replace_malloc.c:255) +==17884== by 0x49289F7: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x4169873: char* std::string::_S_construct(char*, char*, std::allocator const&, std::forward_iterator_tag) (basic_string.tcc:138) +==17884== by 0x457D674: http::server::HTTPRequest::flush(Wt::WebRequest::ResponseState, boost::function) (basic_string.h:1649) +==17884== by 0x43C041E: Wt::WebSession::handleRequest(Wt::WebSession::Handler&) (WebSession.C:1254) +==17884== by 0x43D86A3: Wt::WebController::handleAsyncRequest(Wt::WebRequest*) (WebController.C:638) +==17884== by 0x43D9703: Wt::WebController::handleRequest(Wt::WebRequest*) (WebController.C:512) +==17884== by 0x45BE959: Wt::WServer::handleRequest(Wt::WebRequest*) (WServer.C:372) +==17884== by 0x45C690D: http::server::WtReply::consumeRequestBody(char const*, char const*, http::server::Request::State) (WtReply.C:187) +==17884== by 0x45C7CDB: http::server::WtReply::consumeData(char const*, char const*, http::server::Request::State) (WtReply.C:81) +==17884== by 0x45889DF: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:137) +==17884== by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) +==17884== +==17884== Thread #10 was created +==17884== at 0x4A9A728: clone (clone.S:111) +==17884== by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) +==17884== by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) +==17884== by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) +==17884== by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) +==17884== by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) +==17884== by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) +==17884== by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) +==17884== +==17884== Possible data race during write of size 4 at 0x49816f0 by thread #2 +==17884== at 0x48EF2B9: std::locale::locale(std::locale::_Impl*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x48F1505: std::locale::classic() (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x42679FB: std::basic_string, std::allocator > boost::posix_time::to_simple_string_type(boost::posix_time::ptime) (date_formatting.hpp:85) +==17884== by 0x4266507: Wt::WLogEntry::operator<<(Wt::WLogger::TimeStamp const&) (time_formatters.hpp:184) +==17884== by 0x457F35E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:469) +==17884== by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) +==17884== by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) +==17884== by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) +==17884== by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) +==17884== by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) +==17884== by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) +==17884== by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) +==17884== This conflicts with a previous write of size 4 by thread #10 +==17884== at 0x48EF2B9: std::locale::locale(std::locale::_Impl*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x48F1505: std::locale::classic() (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x42679FB: std::basic_string, std::allocator > boost::posix_time::to_simple_string_type(boost::posix_time::ptime) (date_formatting.hpp:85) +==17884== by 0x4266507: Wt::WLogEntry::operator<<(Wt::WLogger::TimeStamp const&) (time_formatters.hpp:184) +==17884== by 0x43B8DC0: Wt::WebSession::log(std::string const&) const (WebSession.C:131) +==17884== by 0x43C3CB1: Wt::WebSession::~WebSession() (WebSession.C:171) +==17884== by 0x436F078: boost::detail::sp_counted_impl_p::dispose() (checked_delete.hpp:34) +==17884== by 0x804B8F7: boost::detail::shared_count::~shared_count() (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) +==17884== +==17884== Possible data race during write of size 4 at 0x6144d40 by thread #2 +==17884== at 0x45C5106: http::server::WtReply::~WtReply() (WtReply.C:63) +==17884== by 0x45C56B1: http::server::WtReply::~WtReply() (WtReply.C:72) +==17884== by 0x4587AE7: boost::detail::sp_counted_impl_p::dispose() (checked_delete.hpp:34) +==17884== by 0x804B8F7: boost::detail::shared_count::~shared_count() (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) +==17884== by 0x4571179: http::server::Connection::handleWriteResponse() (shared_ptr.hpp:169) +==17884== by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) +==17884== by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) +==17884== by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) +==17884== by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) +==17884== by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) +==17884== by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) +==17884== by 0x45C4041: boost::detail::thread_data, boost::_bi::list2, boost::_bi::value > > >::run() (mem_fn_template.hpp:165) +==17884== This conflicts with a previous read of size 4 by thread #10 +==17884== at 0x45889ED: http::server::RequestParser::parseBody(http::server::Request&, boost::shared_ptr, char const*&, char const*) (RequestParser.C:139) +==17884== by 0x456F58D: http::server::Connection::handleReadBody() (Connection.C:172) +==17884== by 0x4571A8B: http::server::Connection::handleReadRequest0() (Connection.C:120) +==17884== by 0x4571C89: http::server::Connection::handleReadRequest(boost::system::error_code const&, unsigned int) (Connection.C:154) +==17884== by 0x45B6071: boost::asio::detail::handler_queue::handler_wrapper, boost::_bi::list3 >, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (mem_fn_template.hpp:271) +==17884== by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) +==17884== by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) +==17884== by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) +==17884== Address 0x6144d40 is 0 bytes inside a block of size 476 alloc'd +==17884== at 0x402647D: operator new(unsigned int) (vg_replace_malloc.c:255) +==17884== by 0x4586C67: http::server::RequestHandler::handleRequest(http::server::Request&) (RequestHandler.C:145) +==17884== by 0x45719FB: http::server::Connection::handleReadRequest0() (Connection.C:116) +==17884== by 0x4571C89: http::server::Connection::handleReadRequest(boost::system::error_code const&, unsigned int) (Connection.C:154) +==17884== by 0x45B6071: boost::asio::detail::handler_queue::handler_wrapper, boost::_bi::list3 >, boost::arg<1> (*)(), boost::arg<2> (*)()> >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (mem_fn_template.hpp:271) +==17884== by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) +==17884== by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) +==17884== by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) +==17884== by 0x45C4041: boost::detail::thread_data, boost::_bi::list2, boost::_bi::value > > >::run() (mem_fn_template.hpp:165) +==17884== by 0x4B49028: thread_proxy (thread.cpp:120) +==17884== by 0x4026F60: mythread_wrapper (hg_intercepts.c:221) +==17884== by 0x4888E98: start_thread (pthread_create.c:304) +==17884== +==17884== Thread #8 was created +==17884== at 0x4A9A728: clone (clone.S:111) +==17884== by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) +==17884== by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) +==17884== by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) +==17884== by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) +==17884== by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) +==17884== by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) +==17884== by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) +==17884== +==17884== Thread #11 was created +==17884== at 0x4A9A728: clone (clone.S:111) +==17884== by 0x48894B5: pthread_create@@GLIBC_2.1 (createthread.c:256) +==17884== by 0x4026E2D: pthread_create_WRK (hg_intercepts.c:257) +==17884== by 0x4026F8B: pthread_create@* (hg_intercepts.c:288) +==17884== by 0x4B48D7C: boost::thread::start_thread() (thread.cpp:185) +==17884== by 0x45C2C6D: Wt::WServer::start() (thread.hpp:191) +==17884== by 0x45C3A38: Wt::WRun(int, char**, boost::function) (WServer.C:492) +==17884== by 0x804ADED: main (in /home/richel/Projects/Website/CppHelgrindExample3-build-desktop/CppHelgrindExample3) +==17884== +==17884== Possible data race during read of size 4 at 0x497fe8c by thread #8 +==17884== at 0x491C438: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x4265C7A: Wt::WLogger::addLine(std::string const&) const (basic_string.h:2605) +==17884== by 0x426621F: Wt::WLogEntry::~WLogEntry() (WLogger.C:27) +==17884== by 0x457F49E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:464) +==17884== by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) +==17884== by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) +==17884== by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) +==17884== by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) +==17884== by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) +==17884== by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) +==17884== by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) +==17884== by 0x45C4041: boost::detail::thread_data, boost::_bi::list2, boost::_bi::value > > >::run() (mem_fn_template.hpp:165) +==17884== This conflicts with a previous write of size 4 by thread #11 +==17884== at 0x491C53C: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x4265C7A: Wt::WLogger::addLine(std::string const&) const (basic_string.h:2605) +==17884== by 0x426621F: Wt::WLogEntry::~WLogEntry() (WLogger.C:27) +==17884== by 0x457F49E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:464) +==17884== by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) +==17884== by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) +==17884== by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) +==17884== by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) +==17884== +==17884== Possible data race during write of size 4 at 0x497fe8c by thread #8 +==17884== at 0x491C53C: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x4265C7A: Wt::WLogger::addLine(std::string const&) const (basic_string.h:2605) +==17884== by 0x426621F: Wt::WLogEntry::~WLogEntry() (WLogger.C:27) +==17884== by 0x457F49E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:464) +==17884== by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) +==17884== by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) +==17884== by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) +==17884== by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) +==17884== by 0x4598445: boost::asio::detail::task_io_service >::run(boost::system::error_code&) (handler_queue.hpp:39) +==17884== by 0x458E4ED: http::server::Server::run() (io_service.ipp:68) +==17884== by 0x45C413A: Wt::WServerImpl::runThread(Wt::WServer*) (WServer.C:123) +==17884== by 0x45C4041: boost::detail::thread_data, boost::_bi::list2, boost::_bi::value > > >::run() (mem_fn_template.hpp:165) +==17884== This conflicts with a previous write of size 4 by thread #11 +==17884== at 0x491C53C: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14) +==17884== by 0x4265C7A: Wt::WLogger::addLine(std::string const&) const (basic_string.h:2605) +==17884== by 0x426621F: Wt::WLogEntry::~WLogEntry() (WLogger.C:27) +==17884== by 0x457F49E: http::server::Reply::logReply(Wt::WLogger&) (Reply.C:464) +==17884== by 0x4571111: http::server::Connection::handleWriteResponse() (Connection.C:232) +==17884== by 0x4571385: http::server::Connection::handleWriteResponse(boost::system::error_code const&) (Connection.C:257) +==17884== by 0x45BC10F: boost::asio::detail::write_handler >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned int) (mem_fn_template.hpp:156) +==17884== by 0x45BCBD1: boost::asio::detail::handler_queue::handler_wrapper >, std::vector >, boost::asio::detail::transfer_all_t, boost::_bi::bind_t, boost::_bi::list2 >, boost::arg<1> (*)()> > >, boost::system::error_code, unsigned int> >::do_call(boost::asio::detail::handler_queue::handler*) (bind_handler.hpp:96) +==17884== +==17884== +==17884== For counts of detected and suppressed errors, rerun with: -v +==17884== Use --history-level=approx or =none to gain increased speed, at +==17884== the cost of reduced accuracy of conflicting-access information +==17884== ERROR SUMMARY: 35 errors from 9 contexts (suppressed: 9621 from 566) +``` 35 errors! - -  - -  - -  - -  - -  - -  - diff --git a/content/CppInstallErrorEoUint_maxWasNotDeclaredInThisScope.md b/content/CppInstallErrorEoUint_maxWasNotDeclaredInThisScope.md index e4ce88b1..340506f9 100644 --- a/content/CppInstallErrorEoUint_maxWasNotDeclaredInThisScope.md +++ b/content/CppInstallErrorEoUint_maxWasNotDeclaredInThisScope.md @@ -1,304 +1,708 @@ - -  - -  - -  - -  - -  - -([C++](Cpp.md)) [EO install error: 'UINT\_MAX' was not declared in this scope](CppInstallErrorEoUint_maxWasNotDeclaredInThisScope.md) -======================================================================================================================================= - -  +# ([C++](Cpp.md)) [EO install error: 'UINT\_MAX' was not declared in this scope](CppInstallErrorEoUint_maxWasNotDeclaredInThisScope.md) [Install error](CppInstallError.md). -  - -  - -  - -  - -  - -Error description ------------------ - -  +## Error description Operating system: [Ubuntu](http://www.ubuntu.com) 10.04 LTS Lucid Lynx -  - Downloaded the [EO](CppEo.md) source code, version 1.0.1. Extracted the files. -  - Start configure: -  - - ----------------- - ` ./configure ` - ----------------- - -  +``` +./configure +``` Screen output: -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` checking build system type... i686-pc-linux checking host system type... i686-pc-linux checking target system type... i686-pc-linux checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking dependency style of g++... gcc3 checking for a BSD-compatible install... /usr/bin/install -c checking whether ln -s works... yes checking whether make sets $(MAKE)... (cached) yes checking for ranlib... ranlib checking for ar... /usr/bin/ar checking for doxygen... doxygen checking how to run the C++ preprocessor... g++ -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for uint32_t... yes checking for size_t... yes checking for cos in -lm... yes checking use gnuplot for graphical display... (cached) yes checking for gnuplot... gnuplot configure: creating ./config.status config.status: creating Makefile config.status: creating app/Makefile config.status: creating app/mastermind/Makefile config.status: creating app/gprop/Makefile config.status: creating app/gpsymreg/Makefile config.status: creating contrib/Makefile config.status: creating doc/Makefile config.status: creating src/Makefile config.status: creating src/do/Makefile config.status: creating src/es/Makefile config.status: creating src/gp/Makefile config.status: creating src/ga/Makefile config.status: creating src/other/Makefile config.status: creating src/utils/Makefile config.status: creating test/Makefile config.status: creating tutorial/Makefile config.status: creating tutorial/html/Makefile config.status: creating tutorial/Lesson1/Makefile config.status: creating tutorial/Lesson2/Makefile config.status: creating tutorial/Lesson3/Makefile config.status: creating tutorial/Lesson4/Makefile config.status: creating tutorial/Lesson5/Makefile config.status: creating tutorial/Templates/Makefile config.status: creating tutorial/pdf/Makefile config.status: creating win/Makefile config.status: creating config.h config.status: executing depfiles commands` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  +``` +checking build system type... i686-pc-linux +checking host system type... i686-pc-linux +checking target system type... i686-pc-linux +checking for a BSD-compatible install... /usr/bin/install -c +checking whether build environment is sane... yes +checking for gawk... gawk +checking whether make sets $(MAKE)... yes +checking for gcc... gcc +checking for C compiler default output file name... a.out +checking whether the C compiler works... yes +checking whether we are cross compiling... no +checking for suffix of executables... +checking for suffix of object files... o +checking whether we are using the GNU C compiler... yes +checking whether gcc accepts -g... yes +checking for gcc option to accept ANSI C... none needed +checking for style of include used by make... GNU +checking dependency style of gcc... gcc3 +checking for g++... g++ +checking whether we are using the GNU C++ compiler... yes +checking whether g++ accepts -g... yes +checking dependency style of g++... gcc3 +checking for a BSD-compatible install... /usr/bin/install -c +checking whether ln -s works... yes +checking whether make sets $(MAKE)... (cached) yes +checking for ranlib... ranlib +checking for ar... /usr/bin/ar +checking for doxygen... doxygen +checking how to run the C++ preprocessor... g++ -E +checking for egrep... grep -E +checking for ANSI C header files... yes +checking for sys/types.h... yes +checking for sys/stat.h... yes +checking for stdlib.h... yes +checking for string.h... yes +checking for memory.h... yes +checking for strings.h... yes +checking for inttypes.h... yes +checking for stdint.h... yes +checking for unistd.h... yes +checking for uint32_t... yes +checking for size_t... yes +checking for cos in -lm... yes +checking use gnuplot for graphical display... (cached) yes +checking for gnuplot... gnuplot +configure: creating ./config.status +config.status: creating Makefile +config.status: creating app/Makefile +config.status: creating app/mastermind/Makefile +config.status: creating app/gprop/Makefile +config.status: creating app/gpsymreg/Makefile +config.status: creating contrib/Makefile +config.status: creating doc/Makefile +config.status: creating src/Makefile +config.status: creating src/do/Makefile +config.status: creating src/es/Makefile +config.status: creating src/gp/Makefile +config.status: creating src/ga/Makefile +config.status: creating src/other/Makefile +config.status: creating src/utils/Makefile +config.status: creating test/Makefile +config.status: creating tutorial/Makefile +config.status: creating tutorial/html/Makefile +config.status: creating tutorial/Lesson1/Makefile +config.status: creating tutorial/Lesson2/Makefile +config.status: creating tutorial/Lesson3/Makefile +config.status: creating tutorial/Lesson4/Makefile +config.status: creating tutorial/Lesson5/Makefile +config.status: creating tutorial/Templates/Makefile +config.status: creating tutorial/pdf/Makefile +config.status: creating win/Makefile +config.status: creating config.h +config.status: executing depfiles commands +``` Start make: -  - - --------- - ` make` - --------- - -  +``` +make +``` Screen output: -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` make all-recursive make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' Making all in src make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' Making all in es make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_algo_scalar_es.o -MD -MP -MF ".deps/make_algo_scalar_es.Tpo" -c -o make_algo_scalar_es.o make_algo_scalar_es.cpp; \ then mv -f ".deps/make_algo_scalar_es.Tpo" ".deps/make_algo_scalar_es.Po"; else rm -f ".deps/make_algo_scalar_es.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_algo_scalar_real.o -MD -MP -MF ".deps/make_algo_scalar_real.Tpo" -c -o make_algo_scalar_real.o make_algo_scalar_real.cpp; \ then mv -f ".deps/make_algo_scalar_real.Tpo" ".deps/make_algo_scalar_real.Po"; else rm -f ".deps/make_algo_scalar_real.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_es.o -MD -MP -MF ".deps/make_checkpoint_es.Tpo" -c -o make_checkpoint_es.o make_checkpoint_es.cpp; \ then mv -f ".deps/make_checkpoint_es.Tpo" ".deps/make_checkpoint_es.Po"; else rm -f ".deps/make_checkpoint_es.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:34, from make_checkpoint_es.cpp:44: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result In file included from make_checkpoint_es.cpp:44: ../../src/do/make_checkpoint.h: In function 'eoCheckPoint&, eoContinue&)’: ../../src/do/make_checkpoint.h:259: error: 'UINT_MAX’ was not declared in this scope make[3]: *** [make_checkpoint_es.o] Error 1 make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' make: *** [all] Error 2 richel@richel1-desktop:~/Downloads/eo-1.0.1$ make check Making check in src make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' Making check in es make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_es.o -MD -MP -MF ".deps/make_checkpoint_es.Tpo" -c -o make_checkpoint_es.o make_checkpoint_es.cpp; \ then mv -f ".deps/make_checkpoint_es.Tpo" ".deps/make_checkpoint_es.Po"; else rm -f ".deps/make_checkpoint_es.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:34, from make_checkpoint_es.cpp:44: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result In file included from make_checkpoint_es.cpp:44: ../../src/do/make_checkpoint.h: In function 'eoCheckPoint&, eoContinue&)’: ../../src/do/make_checkpoint.h:259: error: 'UINT_MAX’ was not declared in this scope make[2]: *** [make_checkpoint_es.o] Error 1 make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' make[1]: *** [check-recursive] Error 1 make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' make: *** [check-recursive] Error 1` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  +``` +make all-recursive +make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' +Making all in src +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' +Making all in es +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_algo_scalar_es.o -MD -MP -MF ".deps/make_algo_scalar_es.Tpo" -c -o make_algo_scalar_es.o make_algo_scalar_es.cpp; \ +then mv -f ".deps/make_algo_scalar_es.Tpo" ".deps/make_algo_scalar_es.Po"; else rm -f ".deps/make_algo_scalar_es.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_algo_scalar_real.o -MD -MP -MF ".deps/make_algo_scalar_real.Tpo" -c -o make_algo_scalar_real.o make_algo_scalar_real.cpp; \ +then mv -f ".deps/make_algo_scalar_real.Tpo" ".deps/make_algo_scalar_real.Po"; else rm -f ".deps/make_algo_scalar_real.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_es.o -MD -MP -MF ".deps/make_checkpoint_es.Tpo" -c -o make_checkpoint_es.o make_checkpoint_es.cpp; \ +then mv -f ".deps/make_checkpoint_es.Tpo" ".deps/make_checkpoint_es.Po"; else rm -f ".deps/make_checkpoint_es.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:34, +from make_checkpoint_es.cpp:44: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +In file included from make_checkpoint_es.cpp:44: +../../src/do/make_checkpoint.h: In function 'eoCheckPoint&, eoContinue&)’: +../../src/do/make_checkpoint.h:259: error: 'UINT_MAX’ was not declared in this scope +make[3]: *** [make_checkpoint_es.o] Error 1 +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' +make[2]: *** [all-recursive] Error 1 +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' +make[1]: *** [all-recursive] Error 1 +make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' +make: *** [all] Error 2 +richel@richel1-desktop:~/Downloads/eo-1.0.1$ make check +Making check in src +make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' +Making check in es +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_es.o -MD -MP -MF ".deps/make_checkpoint_es.Tpo" -c -o make_checkpoint_es.o make_checkpoint_es.cpp; \ +then mv -f ".deps/make_checkpoint_es.Tpo" ".deps/make_checkpoint_es.Po"; else rm -f ".deps/make_checkpoint_es.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:34, +from make_checkpoint_es.cpp:44: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +In file included from make_checkpoint_es.cpp:44: +../../src/do/make_checkpoint.h: In function 'eoCheckPoint&, eoContinue&)’: +../../src/do/make_checkpoint.h:259: error: 'UINT_MAX’ was not declared in this scope +make[2]: *** [make_checkpoint_es.o] Error 1 +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' +make[1]: *** [check-recursive] Error 1 +make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' +make: *** [check-recursive] Error 1 +``` I zoomed in on the following error: -  - - ----------------------------------------------------------------------------------------- - ` ../../src/do/make_checkpoint.h:259: error: 'UINT_MAX’ was not declared in this scope` - ----------------------------------------------------------------------------------------- - -  +``` +../../src/do/make_checkpoint.h:259: error: 'UINT_MAX’ was not declared in this scope +``` I edited the file checkpoint.h by adding one line, shown below: -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef _make_checkpoint_h #define _make_checkpoint_h #include //Added by Bilderbikkel #include #include // for minimizing_fitness()` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +``` +#ifndef _make_checkpoint_h +#define _make_checkpoint_h -  +#include //Added by RJCB +#include +#include // for minimizing_fitness() +``` Try make again: -  - --------- - ` make` - --------- - -  +``` +make +``` Screen output: -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` make all-recursive make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' Making all in src make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' Making all in es make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_es.o -MD -MP -MF ".deps/make_checkpoint_es.Tpo" -c -o make_checkpoint_es.o make_checkpoint_es.cpp; \ then mv -f ".deps/make_checkpoint_es.Tpo" ".deps/make_checkpoint_es.Po"; else rm -f ".deps/make_checkpoint_es.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:35, from make_checkpoint_es.cpp:44: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_real.o -MD -MP -MF ".deps/make_checkpoint_real.Tpo" -c -o make_checkpoint_real.o make_checkpoint_real.cpp; \ then mv -f ".deps/make_checkpoint_real.Tpo" ".deps/make_checkpoint_real.Po"; else rm -f ".deps/make_checkpoint_real.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:35, from make_checkpoint_real.cpp:44: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_continue_es.o -MD -MP -MF ".deps/make_continue_es.Tpo" -c -o make_continue_es.o make_continue_es.cpp; \ then mv -f ".deps/make_continue_es.Tpo" ".deps/make_continue_es.Po"; else rm -f ".deps/make_continue_es.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_continue_real.o -MD -MP -MF ".deps/make_continue_real.Tpo" -c -o make_continue_real.o make_continue_real.cpp; \ then mv -f ".deps/make_continue_real.Tpo" ".deps/make_continue_real.Po"; else rm -f ".deps/make_continue_real.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_genotype_es.o -MD -MP -MF ".deps/make_genotype_es.Tpo" -c -o make_genotype_es.o make_genotype_es.cpp; \ then mv -f ".deps/make_genotype_es.Tpo" ".deps/make_genotype_es.Po"; else rm -f ".deps/make_genotype_es.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_genotype_real.o -MD -MP -MF ".deps/make_genotype_real.Tpo" -c -o make_genotype_real.o make_genotype_real.cpp; \ then mv -f ".deps/make_genotype_real.Tpo" ".deps/make_genotype_real.Po"; else rm -f ".deps/make_genotype_real.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_op_es.o -MD -MP -MF ".deps/make_op_es.Tpo" -c -o make_op_es.o make_op_es.cpp; \ then mv -f ".deps/make_op_es.Tpo" ".deps/make_op_es.Po"; else rm -f ".deps/make_op_es.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_op_real.o -MD -MP -MF ".deps/make_op_real.Tpo" -c -o make_op_real.o make_op_real.cpp; \ then mv -f ".deps/make_op_real.Tpo" ".deps/make_op_real.Po"; else rm -f ".deps/make_op_real.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_pop_es.o -MD -MP -MF ".deps/make_pop_es.Tpo" -c -o make_pop_es.o make_pop_es.cpp; \ then mv -f ".deps/make_pop_es.Tpo" ".deps/make_pop_es.Po"; else rm -f ".deps/make_pop_es.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_pop_real.o -MD -MP -MF ".deps/make_pop_real.Tpo" -c -o make_pop_real.o make_pop_real.cpp; \ then mv -f ".deps/make_pop_real.Tpo" ".deps/make_pop_real.Po"; else rm -f ".deps/make_pop_real.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_run_es.o -MD -MP -MF ".deps/make_run_es.Tpo" -c -o make_run_es.o make_run_es.cpp; \ then mv -f ".deps/make_run_es.Tpo" ".deps/make_run_es.Po"; else rm -f ".deps/make_run_es.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_run_real.o -MD -MP -MF ".deps/make_run_real.Tpo" -c -o make_run_real.o make_run_real.cpp; \ then mv -f ".deps/make_run_real.Tpo" ".deps/make_run_real.Po"; else rm -f ".deps/make_run_real.Tpo"; exit 1; fi rm -f libes.a /usr/bin/ar cru libes.a make_algo_scalar_es.o make_algo_scalar_real.o make_checkpoint_es.o make_checkpoint_real.o make_continue_es.o make_continue_real.o make_genotype_es.o make_genotype_real.o make_op_es.o make_op_real.o make_pop_es.o make_pop_real.o make_run_es.o make_run_real.o ranlib libes.a if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT eig.o -MD -MP -MF ".deps/eig.Tpo" -c -o eig.o eig.cpp; \ then mv -f ".deps/eig.Tpo" ".deps/eig.Po"; else rm -f ".deps/eig.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT CMAState.o -MD -MP -MF ".deps/CMAState.Tpo" -c -o CMAState.o CMAState.cpp; \ then mv -f ".deps/CMAState.Tpo" ".deps/CMAState.Po"; else rm -f ".deps/CMAState.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT CMAParams.o -MD -MP -MF ".deps/CMAParams.Tpo" -c -o CMAParams.o CMAParams.cpp; \ then mv -f ".deps/CMAParams.Tpo" ".deps/CMAParams.Po"; else rm -f ".deps/CMAParams.Tpo"; exit 1; fi rm -f libcma.a /usr/bin/ar cru libcma.a eig.o CMAState.o CMAParams.o ranlib libcma.a make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' Making all in ga make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_algo_scalar_ga.o -MD -MP -MF ".deps/make_algo_scalar_ga.Tpo" -c -o make_algo_scalar_ga.o make_algo_scalar_ga.cpp; \ then mv -f ".deps/make_algo_scalar_ga.Tpo" ".deps/make_algo_scalar_ga.Po"; else rm -f ".deps/make_algo_scalar_ga.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_checkpoint_ga.o -MD -MP -MF ".deps/make_checkpoint_ga.Tpo" -c -o make_checkpoint_ga.o make_checkpoint_ga.cpp; \ then mv -f ".deps/make_checkpoint_ga.Tpo" ".deps/make_checkpoint_ga.Po"; else rm -f ".deps/make_checkpoint_ga.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:35, from make_checkpoint_ga.cpp:47: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_continue_ga.o -MD -MP -MF ".deps/make_continue_ga.Tpo" -c -o make_continue_ga.o make_continue_ga.cpp; \ then mv -f ".deps/make_continue_ga.Tpo" ".deps/make_continue_ga.Po"; else rm -f ".deps/make_continue_ga.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_genotype_ga.o -MD -MP -MF ".deps/make_genotype_ga.Tpo" -c -o make_genotype_ga.o make_genotype_ga.cpp; \ then mv -f ".deps/make_genotype_ga.Tpo" ".deps/make_genotype_ga.Po"; else rm -f ".deps/make_genotype_ga.Tpo"; exit 1; fi In file included from ../../src/ga/make_genotype_ga.h:30, from make_genotype_ga.cpp:44: ../../src/ga/eoBit.h: In member function 'virtual void eoBit::readFrom(std::istream&)’: ../../src/ga/eoBit.h:104: error: 'transform’ is not a member of 'std’ make[3]: *** [make_genotype_ga.o] Error 1 make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' make: *** [all] Error 2` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  +``` +make all-recursive +make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' +Making all in src +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' +Making all in es +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_es.o -MD -MP -MF ".deps/make_checkpoint_es.Tpo" -c -o make_checkpoint_es.o make_checkpoint_es.cpp; \ +then mv -f ".deps/make_checkpoint_es.Tpo" ".deps/make_checkpoint_es.Po"; else rm -f ".deps/make_checkpoint_es.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:35, +from make_checkpoint_es.cpp:44: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_real.o -MD -MP -MF ".deps/make_checkpoint_real.Tpo" -c -o make_checkpoint_real.o make_checkpoint_real.cpp; \ +then mv -f ".deps/make_checkpoint_real.Tpo" ".deps/make_checkpoint_real.Po"; else rm -f ".deps/make_checkpoint_real.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:35, +from make_checkpoint_real.cpp:44: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_continue_es.o -MD -MP -MF ".deps/make_continue_es.Tpo" -c -o make_continue_es.o make_continue_es.cpp; \ +then mv -f ".deps/make_continue_es.Tpo" ".deps/make_continue_es.Po"; else rm -f ".deps/make_continue_es.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_continue_real.o -MD -MP -MF ".deps/make_continue_real.Tpo" -c -o make_continue_real.o make_continue_real.cpp; \ +then mv -f ".deps/make_continue_real.Tpo" ".deps/make_continue_real.Po"; else rm -f ".deps/make_continue_real.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_genotype_es.o -MD -MP -MF ".deps/make_genotype_es.Tpo" -c -o make_genotype_es.o make_genotype_es.cpp; \ +then mv -f ".deps/make_genotype_es.Tpo" ".deps/make_genotype_es.Po"; else rm -f ".deps/make_genotype_es.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_genotype_real.o -MD -MP -MF ".deps/make_genotype_real.Tpo" -c -o make_genotype_real.o make_genotype_real.cpp; \ +then mv -f ".deps/make_genotype_real.Tpo" ".deps/make_genotype_real.Po"; else rm -f ".deps/make_genotype_real.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_op_es.o -MD -MP -MF ".deps/make_op_es.Tpo" -c -o make_op_es.o make_op_es.cpp; \ +then mv -f ".deps/make_op_es.Tpo" ".deps/make_op_es.Po"; else rm -f ".deps/make_op_es.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_op_real.o -MD -MP -MF ".deps/make_op_real.Tpo" -c -o make_op_real.o make_op_real.cpp; \ +then mv -f ".deps/make_op_real.Tpo" ".deps/make_op_real.Po"; else rm -f ".deps/make_op_real.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_pop_es.o -MD -MP -MF ".deps/make_pop_es.Tpo" -c -o make_pop_es.o make_pop_es.cpp; \ +then mv -f ".deps/make_pop_es.Tpo" ".deps/make_pop_es.Po"; else rm -f ".deps/make_pop_es.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_pop_real.o -MD -MP -MF ".deps/make_pop_real.Tpo" -c -o make_pop_real.o make_pop_real.cpp; \ +then mv -f ".deps/make_pop_real.Tpo" ".deps/make_pop_real.Po"; else rm -f ".deps/make_pop_real.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_run_es.o -MD -MP -MF ".deps/make_run_es.Tpo" -c -o make_run_es.o make_run_es.cpp; \ +then mv -f ".deps/make_run_es.Tpo" ".deps/make_run_es.Po"; else rm -f ".deps/make_run_es.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_run_real.o -MD -MP -MF ".deps/make_run_real.Tpo" -c -o make_run_real.o make_run_real.cpp; \ +then mv -f ".deps/make_run_real.Tpo" ".deps/make_run_real.Po"; else rm -f ".deps/make_run_real.Tpo"; exit 1; fi +rm -f libes.a +/usr/bin/ar cru libes.a make_algo_scalar_es.o make_algo_scalar_real.o make_checkpoint_es.o make_checkpoint_real.o make_continue_es.o make_continue_real.o make_genotype_es.o make_genotype_real.o make_op_es.o make_op_real.o make_pop_es.o make_pop_real.o make_run_es.o make_run_real.o +ranlib libes.a +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT eig.o -MD -MP -MF ".deps/eig.Tpo" -c -o eig.o eig.cpp; \ +then mv -f ".deps/eig.Tpo" ".deps/eig.Po"; else rm -f ".deps/eig.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT CMAState.o -MD -MP -MF ".deps/CMAState.Tpo" -c -o CMAState.o CMAState.cpp; \ +then mv -f ".deps/CMAState.Tpo" ".deps/CMAState.Po"; else rm -f ".deps/CMAState.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT CMAParams.o -MD -MP -MF ".deps/CMAParams.Tpo" -c -o CMAParams.o CMAParams.cpp; \ +then mv -f ".deps/CMAParams.Tpo" ".deps/CMAParams.Po"; else rm -f ".deps/CMAParams.Tpo"; exit 1; fi +rm -f libcma.a +/usr/bin/ar cru libcma.a eig.o CMAState.o CMAParams.o +ranlib libcma.a +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' +Making all in ga +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_algo_scalar_ga.o -MD -MP -MF ".deps/make_algo_scalar_ga.Tpo" -c -o make_algo_scalar_ga.o make_algo_scalar_ga.cpp; \ +then mv -f ".deps/make_algo_scalar_ga.Tpo" ".deps/make_algo_scalar_ga.Po"; else rm -f ".deps/make_algo_scalar_ga.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_checkpoint_ga.o -MD -MP -MF ".deps/make_checkpoint_ga.Tpo" -c -o make_checkpoint_ga.o make_checkpoint_ga.cpp; \ +then mv -f ".deps/make_checkpoint_ga.Tpo" ".deps/make_checkpoint_ga.Po"; else rm -f ".deps/make_checkpoint_ga.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:35, +from make_checkpoint_ga.cpp:47: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_continue_ga.o -MD -MP -MF ".deps/make_continue_ga.Tpo" -c -o make_continue_ga.o make_continue_ga.cpp; \ +then mv -f ".deps/make_continue_ga.Tpo" ".deps/make_continue_ga.Po"; else rm -f ".deps/make_continue_ga.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_genotype_ga.o -MD -MP -MF ".deps/make_genotype_ga.Tpo" -c -o make_genotype_ga.o make_genotype_ga.cpp; \ +then mv -f ".deps/make_genotype_ga.Tpo" ".deps/make_genotype_ga.Po"; else rm -f ".deps/make_genotype_ga.Tpo"; exit 1; fi +In file included from ../../src/ga/make_genotype_ga.h:30, +from make_genotype_ga.cpp:44: +../../src/ga/eoBit.h: In member function 'virtual void eoBit::readFrom(std::istream&)’: +../../src/ga/eoBit.h:104: error: 'transform’ is not a member of 'std’ +make[3]: *** [make_genotype_ga.o] Error 1 +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' +make[2]: *** [all-recursive] Error 1 +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' +make[1]: *** [all-recursive] Error 1 +make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' +make: *** [all] Error 2 +``` I zoomed in on the following error: -  - - -------------------------------------------------------------------------- - ` ../../src/ga/eoBit.h:104: error: 'transform’ is not a member of 'std’` - -------------------------------------------------------------------------- - -  +``` +../../src/ga/eoBit.h:104: error: 'transform’ is not a member of 'std’ +``` I edited the file eoBit.h by adding one line, shown below: -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef eoBit_h #define eoBit_h //----------------------------------------------------------------------------- #include     // std::ostream, std::istream #include   // bind2nd #include       // std::string #include    // Added by Bilderbikkel` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +``` +#ifndef eoBit_h +#define eoBit_h -  +//----------------------------------------------------------------------------- +#include // std::ostream, std::istream +#include // bind2nd +#include // std::string +#include // Added by RJCB +``` Try make again: -  - - --------- - ` make` - --------- - -  +``` +make +``` Screen output: -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ` make all-recursive make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' Making all in src make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' Making all in es make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' Making all in ga make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_algo_scalar_ga.o -MD -MP -MF ".deps/make_algo_scalar_ga.Tpo" -c -o make_algo_scalar_ga.o make_algo_scalar_ga.cpp; \ then mv -f ".deps/make_algo_scalar_ga.Tpo" ".deps/make_algo_scalar_ga.Po"; else rm -f ".deps/make_algo_scalar_ga.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_checkpoint_ga.o -MD -MP -MF ".deps/make_checkpoint_ga.Tpo" -c -o make_checkpoint_ga.o make_checkpoint_ga.cpp; \ then mv -f ".deps/make_checkpoint_ga.Tpo" ".deps/make_checkpoint_ga.Po"; else rm -f ".deps/make_checkpoint_ga.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:35, from make_checkpoint_ga.cpp:47: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_continue_ga.o -MD -MP -MF ".deps/make_continue_ga.Tpo" -c -o make_continue_ga.o make_continue_ga.cpp; \ then mv -f ".deps/make_continue_ga.Tpo" ".deps/make_continue_ga.Po"; else rm -f ".deps/make_continue_ga.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_genotype_ga.o -MD -MP -MF ".deps/make_genotype_ga.Tpo" -c -o make_genotype_ga.o make_genotype_ga.cpp; \ then mv -f ".deps/make_genotype_ga.Tpo" ".deps/make_genotype_ga.Po"; else rm -f ".deps/make_genotype_ga.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_op_ga.o -MD -MP -MF ".deps/make_op_ga.Tpo" -c -o make_op_ga.o make_op_ga.cpp; \ then mv -f ".deps/make_op_ga.Tpo" ".deps/make_op_ga.Po"; else rm -f ".deps/make_op_ga.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_pop_ga.o -MD -MP -MF ".deps/make_pop_ga.Tpo" -c -o make_pop_ga.o make_pop_ga.cpp; \ then mv -f ".deps/make_pop_ga.Tpo" ".deps/make_pop_ga.Po"; else rm -f ".deps/make_pop_ga.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_run_ga.o -MD -MP -MF ".deps/make_run_ga.Tpo" -c -o make_run_ga.o make_run_ga.cpp; \ then mv -f ".deps/make_run_ga.Tpo" ".deps/make_run_ga.Po"; else rm -f ".deps/make_run_ga.Tpo"; exit 1; fi rm -f libga.a /usr/bin/ar cru libga.a make_algo_scalar_ga.o make_checkpoint_ga.o make_continue_ga.o make_genotype_ga.o make_op_ga.o make_pop_ga.o make_run_ga.o ranlib libga.a make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' Making all in gp make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/gp' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/gp' Making all in do make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/do' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/do' Making all in utils make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/utils' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoData.o -MD -MP -MF ".deps/eoData.Tpo" -c -o eoData.o eoData.cpp; \ then mv -f ".deps/eoData.Tpo" ".deps/eoData.Po"; else rm -f ".deps/eoData.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoFileMonitor.o -MD -MP -MF ".deps/eoFileMonitor.Tpo" -c -o eoFileMonitor.o eoFileMonitor.cpp; \ then mv -f ".deps/eoFileMonitor.Tpo" ".deps/eoFileMonitor.Po"; else rm -f ".deps/eoFileMonitor.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot.o -MD -MP -MF ".deps/eoGnuplot.Tpo" -c -o eoGnuplot.o eoGnuplot.cpp; \ then mv -f ".deps/eoGnuplot.Tpo" ".deps/eoGnuplot.Po"; else rm -f ".deps/eoGnuplot.Tpo"; exit 1; fi eoGnuplot.cpp: In member function 'void eoGnuplot::initGnuPlot(std::string, std::string)’: eoGnuplot.cpp:76: error: 'strdup’ was not declared in this scope eoGnuplot.cpp:82: warning: deprecated conversion from string constant to 'char*’ make[3]: *** [eoGnuplot.o] Error 1 make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/utils' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' make: *** [all] Error 2` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - -  +``` +make all-recursive +make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' +Making all in src +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' +Making all in es +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' +Making all in ga +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_algo_scalar_ga.o -MD -MP -MF ".deps/make_algo_scalar_ga.Tpo" -c -o make_algo_scalar_ga.o make_algo_scalar_ga.cpp; \ +then mv -f ".deps/make_algo_scalar_ga.Tpo" ".deps/make_algo_scalar_ga.Po"; else rm -f ".deps/make_algo_scalar_ga.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_checkpoint_ga.o -MD -MP -MF ".deps/make_checkpoint_ga.Tpo" -c -o make_checkpoint_ga.o make_checkpoint_ga.cpp; \ +then mv -f ".deps/make_checkpoint_ga.Tpo" ".deps/make_checkpoint_ga.Po"; else rm -f ".deps/make_checkpoint_ga.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:35, +from make_checkpoint_ga.cpp:47: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:82: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_continue_ga.o -MD -MP -MF ".deps/make_continue_ga.Tpo" -c -o make_continue_ga.o make_continue_ga.cpp; \ +then mv -f ".deps/make_continue_ga.Tpo" ".deps/make_continue_ga.Po"; else rm -f ".deps/make_continue_ga.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_genotype_ga.o -MD -MP -MF ".deps/make_genotype_ga.Tpo" -c -o make_genotype_ga.o make_genotype_ga.cpp; \ +then mv -f ".deps/make_genotype_ga.Tpo" ".deps/make_genotype_ga.Po"; else rm -f ".deps/make_genotype_ga.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_op_ga.o -MD -MP -MF ".deps/make_op_ga.Tpo" -c -o make_op_ga.o make_op_ga.cpp; \ +then mv -f ".deps/make_op_ga.Tpo" ".deps/make_op_ga.Po"; else rm -f ".deps/make_op_ga.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_pop_ga.o -MD -MP -MF ".deps/make_pop_ga.Tpo" -c -o make_pop_ga.o make_pop_ga.cpp; \ +then mv -f ".deps/make_pop_ga.Tpo" ".deps/make_pop_ga.Po"; else rm -f ".deps/make_pop_ga.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_run_ga.o -MD -MP -MF ".deps/make_run_ga.Tpo" -c -o make_run_ga.o make_run_ga.cpp; \ +then mv -f ".deps/make_run_ga.Tpo" ".deps/make_run_ga.Po"; else rm -f ".deps/make_run_ga.Tpo"; exit 1; fi +rm -f libga.a +/usr/bin/ar cru libga.a make_algo_scalar_ga.o make_checkpoint_ga.o make_continue_ga.o make_genotype_ga.o make_op_ga.o make_pop_ga.o make_run_ga.o +ranlib libga.a +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' +Making all in gp +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/gp' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/gp' +Making all in do +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/do' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/do' +Making all in utils +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/utils' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoData.o -MD -MP -MF ".deps/eoData.Tpo" -c -o eoData.o eoData.cpp; \ +then mv -f ".deps/eoData.Tpo" ".deps/eoData.Po"; else rm -f ".deps/eoData.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoFileMonitor.o -MD -MP -MF ".deps/eoFileMonitor.Tpo" -c -o eoFileMonitor.o eoFileMonitor.cpp; \ +then mv -f ".deps/eoFileMonitor.Tpo" ".deps/eoFileMonitor.Po"; else rm -f ".deps/eoFileMonitor.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot.o -MD -MP -MF ".deps/eoGnuplot.Tpo" -c -o eoGnuplot.o eoGnuplot.cpp; \ +then mv -f ".deps/eoGnuplot.Tpo" ".deps/eoGnuplot.Po"; else rm -f ".deps/eoGnuplot.Tpo"; exit 1; fi +eoGnuplot.cpp: In member function 'void eoGnuplot::initGnuPlot(std::string, std::string)’: +eoGnuplot.cpp:76: error: 'strdup’ was not declared in this scope +eoGnuplot.cpp:82: warning: deprecated conversion from string constant to 'char*’ +make[3]: *** [eoGnuplot.o] Error 1 +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/utils' +make[2]: *** [all-recursive] Error 1 +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' +make[1]: *** [all-recursive] Error 1 +make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' +make: *** [all] Error 2 +``` I zoomed in on the following error: -  - - --------------------------------------------------------------------- - ` eoGnuplot.cpp:76: error: 'strdup’ was not declared in this scope` - --------------------------------------------------------------------- - -  +``` +eoGnuplot.cpp:76: error: 'strdup’ was not declared in this scope +``` I edited the file scr/utils/eognuplot.cpp by adding one line, shown below: -  +``` +#ifdef HAVE_CONFIG_H +#include +#endif - ----------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifdef HAVE_CONFIG_H #include #endif #include //Added by Bilderbikkel #include #include #include "eoGnuplot.h" ` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------- +#include //Added by RJCB +#include +#include -  +#include "eoGnuplot.h" +``` Try make again: -  - - --------- - ` make` - --------- - -  +``` +make +``` Screen output: -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ` make all-recursive make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' Making all in src make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' Making all in es make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' Making all in ga make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' Making all in gp make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/gp' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/gp' Making all in do make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/do' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/do' Making all in utils make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/utils' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot.o -MD -MP -MF ".deps/eoGnuplot.Tpo" -c -o eoGnuplot.o eoGnuplot.cpp; \ then mv -f ".deps/eoGnuplot.Tpo" ".deps/eoGnuplot.Po"; else rm -f ".deps/eoGnuplot.Tpo"; exit 1; fi eoGnuplot.cpp: In member function 'void eoGnuplot::initGnuPlot(std::string, std::string)’: eoGnuplot.cpp:83: warning: deprecated conversion from string constant to 'char*’ if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot1DMonitor.o -MD -MP -MF ".deps/eoGnuplot1DMonitor.Tpo" -c -o eoGnuplot1DMonitor.o eoGnuplot1DMonitor.cpp; \ then mv -f ".deps/eoGnuplot1DMonitor.Tpo" ".deps/eoGnuplot1DMonitor.Po"; else rm -f ".deps/eoGnuplot1DMonitor.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot1DSnapshot.o -MD -MP -MF ".deps/eoGnuplot1DSnapshot.Tpo" -c -o eoGnuplot1DSnapshot.o eoGnuplot1DSnapshot.cpp; \ then mv -f ".deps/eoGnuplot1DSnapshot.Tpo" ".deps/eoGnuplot1DSnapshot.Po"; else rm -f ".deps/eoGnuplot1DSnapshot.Tpo"; exit 1; fi In file included from eoGnuplot1DSnapshot.h:38, from eoGnuplot1DSnapshot.cpp:5: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:66: error: 'system’ was not declared in this scope make[3]: *** [eoGnuplot1DSnapshot.o] Error 1 make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/utils' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' make: *** [all] Error 2` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - -  +``` +make all-recursive +make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' +Making all in src +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' +Making all in es +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' +Making all in ga +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' +Making all in gp +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/gp' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/gp' +Making all in do +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/do' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/do' +Making all in utils +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/utils' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot.o -MD -MP -MF ".deps/eoGnuplot.Tpo" -c -o eoGnuplot.o eoGnuplot.cpp; \ +then mv -f ".deps/eoGnuplot.Tpo" ".deps/eoGnuplot.Po"; else rm -f ".deps/eoGnuplot.Tpo"; exit 1; fi +eoGnuplot.cpp: In member function 'void eoGnuplot::initGnuPlot(std::string, std::string)’: +eoGnuplot.cpp:83: warning: deprecated conversion from string constant to 'char*’ +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot1DMonitor.o -MD -MP -MF ".deps/eoGnuplot1DMonitor.Tpo" -c -o eoGnuplot1DMonitor.o eoGnuplot1DMonitor.cpp; \ +then mv -f ".deps/eoGnuplot1DMonitor.Tpo" ".deps/eoGnuplot1DMonitor.Po"; else rm -f ".deps/eoGnuplot1DMonitor.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot1DSnapshot.o -MD -MP -MF ".deps/eoGnuplot1DSnapshot.Tpo" -c -o eoGnuplot1DSnapshot.o eoGnuplot1DSnapshot.cpp; \ +then mv -f ".deps/eoGnuplot1DSnapshot.Tpo" ".deps/eoGnuplot1DSnapshot.Po"; else rm -f ".deps/eoGnuplot1DSnapshot.Tpo"; exit 1; fi +In file included from eoGnuplot1DSnapshot.h:38, +from eoGnuplot1DSnapshot.cpp:5: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:66: error: 'system’ was not declared in this scope +make[3]: *** [eoGnuplot1DSnapshot.o] Error 1 +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/utils' +make[2]: *** [all-recursive] Error 1 +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' +make[1]: *** [all-recursive] Error 1 +make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' +make: *** [all] Error 2 +``` I zoomed in on the following error: -  - - ---------------------------------------------------------------------------------------- - ` ../../src/utils/eoFileSnapshot.h:66: error: 'system’ was not declared in this scope` - ---------------------------------------------------------------------------------------- - -  +``` +../../src/utils/eoFileSnapshot.h:66: error: 'system’ was not declared in this scope +``` I edited the file scr/utils/eoFileSnapshot.h by adding one line, shown below: -  +``` +#ifndef _eoFileSnapshot_h +#define _eoFileSnapshot_h - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef _eoFileSnapshot_h #define _eoFileSnapshot_h #include //Added by Bilderbikkel #include #include #include #include #include ` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  +#include //Added by RJCB +#include +#include +#include +#include +#include +``` Try make again: -  - - --------- - ` make` - --------- - -  +``` +make +``` Screen output: -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` make all-recursive make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' Making all in src make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' Making all in es make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_es.o -MD -MP -MF ".deps/make_checkpoint_es.Tpo" -c -o make_checkpoint_es.o make_checkpoint_es.cpp; \ then mv -f ".deps/make_checkpoint_es.Tpo" ".deps/make_checkpoint_es.Po"; else rm -f ".deps/make_checkpoint_es.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:35, from make_checkpoint_es.cpp:44: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_real.o -MD -MP -MF ".deps/make_checkpoint_real.Tpo" -c -o make_checkpoint_real.o make_checkpoint_real.cpp; \ then mv -f ".deps/make_checkpoint_real.Tpo" ".deps/make_checkpoint_real.Po"; else rm -f ".deps/make_checkpoint_real.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:35, from make_checkpoint_real.cpp:44: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result rm -f libes.a /usr/bin/ar cru libes.a make_algo_scalar_es.o make_algo_scalar_real.o make_checkpoint_es.o make_checkpoint_real.o make_continue_es.o make_continue_real.o make_genotype_es.o make_genotype_real.o make_op_es.o make_op_real.o make_pop_es.o make_pop_real.o make_run_es.o make_run_real.o ranlib libes.a make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' Making all in ga make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_checkpoint_ga.o -MD -MP -MF ".deps/make_checkpoint_ga.Tpo" -c -o make_checkpoint_ga.o make_checkpoint_ga.cpp; \ then mv -f ".deps/make_checkpoint_ga.Tpo" ".deps/make_checkpoint_ga.Po"; else rm -f ".deps/make_checkpoint_ga.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/do/make_checkpoint.h:35, from make_checkpoint_ga.cpp:47: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result rm -f libga.a /usr/bin/ar cru libga.a make_algo_scalar_ga.o make_checkpoint_ga.o make_continue_ga.o make_genotype_ga.o make_op_ga.o make_pop_ga.o make_run_ga.o ranlib libga.a make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' Making all in gp make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/gp' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/gp' Making all in do make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/do' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/do' Making all in utils make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/utils' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot.o -MD -MP -MF ".deps/eoGnuplot.Tpo" -c -o eoGnuplot.o eoGnuplot.cpp; \ then mv -f ".deps/eoGnuplot.Tpo" ".deps/eoGnuplot.Po"; else rm -f ".deps/eoGnuplot.Tpo"; exit 1; fi eoGnuplot.cpp: In member function 'void eoGnuplot::initGnuPlot(std::string, std::string)’: eoGnuplot.cpp:83: warning: deprecated conversion from string constant to 'char*’ if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot1DSnapshot.o -MD -MP -MF ".deps/eoGnuplot1DSnapshot.Tpo" -c -o eoGnuplot1DSnapshot.o eoGnuplot1DSnapshot.cpp; \ then mv -f ".deps/eoGnuplot1DSnapshot.Tpo" ".deps/eoGnuplot1DSnapshot.Po"; else rm -f ".deps/eoGnuplot1DSnapshot.Tpo"; exit 1; fi In file included from eoGnuplot1DSnapshot.h:38, from eoGnuplot1DSnapshot.cpp:5: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoIntBounds.o -MD -MP -MF ".deps/eoIntBounds.Tpo" -c -o eoIntBounds.o eoIntBounds.cpp; \ then mv -f ".deps/eoIntBounds.Tpo" ".deps/eoIntBounds.Po"; else rm -f ".deps/eoIntBounds.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoParser.o -MD -MP -MF ".deps/eoParser.Tpo" -c -o eoParser.o eoParser.cpp; \ then mv -f ".deps/eoParser.Tpo" ".deps/eoParser.Po"; else rm -f ".deps/eoParser.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoRealBounds.o -MD -MP -MF ".deps/eoRealBounds.Tpo" -c -o eoRealBounds.o eoRealBounds.cpp; \ then mv -f ".deps/eoRealBounds.Tpo" ".deps/eoRealBounds.Po"; else rm -f ".deps/eoRealBounds.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoRNG.o -MD -MP -MF ".deps/eoRNG.Tpo" -c -o eoRNG.o eoRNG.cpp; \ then mv -f ".deps/eoRNG.Tpo" ".deps/eoRNG.Po"; else rm -f ".deps/eoRNG.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoState.o -MD -MP -MF ".deps/eoState.Tpo" -c -o eoState.o eoState.cpp; \ then mv -f ".deps/eoState.Tpo" ".deps/eoState.Po"; else rm -f ".deps/eoState.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoStdoutMonitor.o -MD -MP -MF ".deps/eoStdoutMonitor.Tpo" -c -o eoStdoutMonitor.o eoStdoutMonitor.cpp; \ then mv -f ".deps/eoStdoutMonitor.Tpo" ".deps/eoStdoutMonitor.Po"; else rm -f ".deps/eoStdoutMonitor.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoUpdater.o -MD -MP -MF ".deps/eoUpdater.Tpo" -c -o eoUpdater.o eoUpdater.cpp; \ then mv -f ".deps/eoUpdater.Tpo" ".deps/eoUpdater.Po"; else rm -f ".deps/eoUpdater.Tpo"; exit 1; fi if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT make_help.o -MD -MP -MF ".deps/make_help.Tpo" -c -o make_help.o make_help.cpp; \ then mv -f ".deps/make_help.Tpo" ".deps/make_help.Po"; else rm -f ".deps/make_help.Tpo"; exit 1; fi make_help.cpp: In function 'void make_help(eoParser&)’: make_help.cpp:68: error: 'exit’ was not declared in this scope make_help.cpp: In function 'bool testDirRes(std::string, bool)’: make_help.cpp:82: error: 'system’ was not declared in this scope make[3]: *** [make_help.o] Error 1 make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/utils' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' make: *** [all] Error 2` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  +``` +make all-recursive +make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' +Making all in src +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' +Making all in es +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_es.o -MD -MP -MF ".deps/make_checkpoint_es.Tpo" -c -o make_checkpoint_es.o make_checkpoint_es.cpp; \ +then mv -f ".deps/make_checkpoint_es.Tpo" ".deps/make_checkpoint_es.Po"; else rm -f ".deps/make_checkpoint_es.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:35, +from make_checkpoint_es.cpp:44: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT make_checkpoint_real.o -MD -MP -MF ".deps/make_checkpoint_real.Tpo" -c -o make_checkpoint_real.o make_checkpoint_real.cpp; \ +then mv -f ".deps/make_checkpoint_real.Tpo" ".deps/make_checkpoint_real.Po"; else rm -f ".deps/make_checkpoint_real.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:35, +from make_checkpoint_real.cpp:44: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +rm -f libes.a +/usr/bin/ar cru libes.a make_algo_scalar_es.o make_algo_scalar_real.o make_checkpoint_es.o make_checkpoint_real.o make_continue_es.o make_continue_real.o make_genotype_es.o make_genotype_real.o make_op_es.o make_op_real.o make_pop_es.o make_pop_real.o make_run_es.o make_run_real.o +ranlib libes.a +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' +Making all in ga +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -I../../src -g -O2 -MT make_checkpoint_ga.o -MD -MP -MF ".deps/make_checkpoint_ga.Tpo" -c -o make_checkpoint_ga.o make_checkpoint_ga.cpp; \ +then mv -f ".deps/make_checkpoint_ga.Tpo" ".deps/make_checkpoint_ga.Po"; else rm -f ".deps/make_checkpoint_ga.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/do/make_checkpoint.h:35, +from make_checkpoint_ga.cpp:47: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +rm -f libga.a +/usr/bin/ar cru libga.a make_algo_scalar_ga.o make_checkpoint_ga.o make_continue_ga.o make_genotype_ga.o make_op_ga.o make_pop_ga.o make_run_ga.o +ranlib libga.a +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' +Making all in gp +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/gp' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/gp' +Making all in do +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/do' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/do' +Making all in utils +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/utils' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot.o -MD -MP -MF ".deps/eoGnuplot.Tpo" -c -o eoGnuplot.o eoGnuplot.cpp; \ +then mv -f ".deps/eoGnuplot.Tpo" ".deps/eoGnuplot.Po"; else rm -f ".deps/eoGnuplot.Tpo"; exit 1; fi +eoGnuplot.cpp: In member function 'void eoGnuplot::initGnuPlot(std::string, std::string)’: +eoGnuplot.cpp:83: warning: deprecated conversion from string constant to 'char*’ +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoGnuplot1DSnapshot.o -MD -MP -MF ".deps/eoGnuplot1DSnapshot.Tpo" -c -o eoGnuplot1DSnapshot.o eoGnuplot1DSnapshot.cpp; \ +then mv -f ".deps/eoGnuplot1DSnapshot.Tpo" ".deps/eoGnuplot1DSnapshot.Po"; else rm -f ".deps/eoGnuplot1DSnapshot.Tpo"; exit 1; fi +In file included from eoGnuplot1DSnapshot.h:38, +from eoGnuplot1DSnapshot.cpp:5: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoIntBounds.o -MD -MP -MF ".deps/eoIntBounds.Tpo" -c -o eoIntBounds.o eoIntBounds.cpp; \ +then mv -f ".deps/eoIntBounds.Tpo" ".deps/eoIntBounds.Po"; else rm -f ".deps/eoIntBounds.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoParser.o -MD -MP -MF ".deps/eoParser.Tpo" -c -o eoParser.o eoParser.cpp; \ +then mv -f ".deps/eoParser.Tpo" ".deps/eoParser.Po"; else rm -f ".deps/eoParser.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoRealBounds.o -MD -MP -MF ".deps/eoRealBounds.Tpo" -c -o eoRealBounds.o eoRealBounds.cpp; \ +then mv -f ".deps/eoRealBounds.Tpo" ".deps/eoRealBounds.Po"; else rm -f ".deps/eoRealBounds.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoRNG.o -MD -MP -MF ".deps/eoRNG.Tpo" -c -o eoRNG.o eoRNG.cpp; \ +then mv -f ".deps/eoRNG.Tpo" ".deps/eoRNG.Po"; else rm -f ".deps/eoRNG.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoState.o -MD -MP -MF ".deps/eoState.Tpo" -c -o eoState.o eoState.cpp; \ +then mv -f ".deps/eoState.Tpo" ".deps/eoState.Po"; else rm -f ".deps/eoState.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoStdoutMonitor.o -MD -MP -MF ".deps/eoStdoutMonitor.Tpo" -c -o eoStdoutMonitor.o eoStdoutMonitor.cpp; \ +then mv -f ".deps/eoStdoutMonitor.Tpo" ".deps/eoStdoutMonitor.Po"; else rm -f ".deps/eoStdoutMonitor.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT eoUpdater.o -MD -MP -MF ".deps/eoUpdater.Tpo" -c -o eoUpdater.o eoUpdater.cpp; \ +then mv -f ".deps/eoUpdater.Tpo" ".deps/eoUpdater.Po"; else rm -f ".deps/eoUpdater.Tpo"; exit 1; fi +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -DGNUPLOT_PROGRAM=\"gnuplot\" -g -O2 -MT make_help.o -MD -MP -MF ".deps/make_help.Tpo" -c -o make_help.o make_help.cpp; \ +then mv -f ".deps/make_help.Tpo" ".deps/make_help.Po"; else rm -f ".deps/make_help.Tpo"; exit 1; fi +make_help.cpp: In function 'void make_help(eoParser&)’: +make_help.cpp:68: error: 'exit’ was not declared in this scope +make_help.cpp: In function 'bool testDirRes(std::string, bool)’: +make_help.cpp:82: error: 'system’ was not declared in this scope +make[3]: *** [make_help.o] Error 1 +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/utils' +make[2]: *** [all-recursive] Error 1 +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' +make[1]: *** [all-recursive] Error 1 +make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' +make: *** [all] Error 2 +``` I zoomed in on the following error: -  - - --------------------------------------------------------------------- - ` make_help.cpp:82: error: 'system’ was not declared in this scope` - --------------------------------------------------------------------- - -  +``` +make_help.cpp:82: error: 'system’ was not declared in this scope +``` I edited the file scr/utils/make\_help.cpp by adding one line, shown below: -  +``` + +#ifdef _MSC_VER +// to avoid long name warnings +#pragma warning(disable:4786) +#endif - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifdef _MSC_VER // to avoid long name warnings #pragma warning(disable:4786) #endif #include //Added by Bilderbikkel #include #include #include using namespace std;` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +#include //Added by RJCB +#include +#include +#include -  +using namespace std; +``` Try make again: -  - - --------- - ` make` - --------- - -  +``` +make +``` Screen output: -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` make all-recursive make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' Making all in src make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' Making all in es make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' Making all in ga make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' Making all in gp make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/gp' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/gp' Making all in do make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/do' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/do' Making all in utils make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/utils' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/utils' Making all in other make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/other' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/other' make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' make[3]: Nothing to be done for 'all-am'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' Making all in doc make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/doc' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/doc' Making all in contrib make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/contrib' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/contrib' Making all in win make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/win' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/win' Making all in app make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/app' Making all in mastermind make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/app/mastermind' make[3]: Nothing to be done for 'all'. make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/app/mastermind' Making all in gprop make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/app/gprop' if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT gprop.o -MD -MP -MF ".deps/gprop.Tpo" -c -o gprop.o gprop.cpp; \ then mv -f ".deps/gprop.Tpo" ".deps/gprop.Po"; else rm -f ".deps/gprop.Tpo"; exit 1; fi In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, from ../../src/utils/checkpointing:9, from ../../src/eo:135, from gprop.cpp:11: ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result ../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: ../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result gprop.cpp: At global scope: gprop.cpp:37: error: conflicting declaration 'const std::string& s’ gprop.cpp:37: error: 's’ has a previous declaration as 'mlp::set& s’ gprop.cpp: In function 'void arg(int, char**)’: gprop.cpp:37: error: too many arguments to function 'void load_file(mlp::set&)’ gprop.cpp:81: error: at this point in file gprop.cpp:37: error: too many arguments to function 'void load_file(mlp::set&)’ gprop.cpp:82: error: at this point in file gprop.cpp:37: error: too many arguments to function 'void load_file(mlp::set&)’ gprop.cpp:83: error: at this point in file make[3]: *** [gprop.o] Error 1 make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/app/gprop' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/app' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' make: *** [all] Error 2` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  +``` +make all-recursive +make[1]: Entering directory '/home/richel/Downloads/eo-1.0.1' +Making all in src +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' +Making all in es +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/es' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/es' +Making all in ga +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/ga' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/ga' +Making all in gp +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/gp' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/gp' +Making all in do +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/do' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/do' +Making all in utils +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/utils' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/utils' +Making all in other +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src/other' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src/other' +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/src' +make[3]: Nothing to be done for 'all-am'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/src' +Making all in doc +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/doc' +make[2]: Nothing to be done for 'all'. +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/doc' +Making all in contrib +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/contrib' +make[2]: Nothing to be done for 'all'. +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/contrib' +Making all in win +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/win' +make[2]: Nothing to be done for 'all'. +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/win' +Making all in app +make[2]: Entering directory '/home/richel/Downloads/eo-1.0.1/app' +Making all in mastermind +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/app/mastermind' +make[3]: Nothing to be done for 'all'. +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/app/mastermind' +Making all in gprop +make[3]: Entering directory '/home/richel/Downloads/eo-1.0.1/app/gprop' +if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../src -g -O2 -MT gprop.o -MD -MP -MF ".deps/gprop.Tpo" -c -o gprop.o gprop.cpp; \ +then mv -f ".deps/gprop.Tpo" ".deps/gprop.Po"; else rm -f ".deps/gprop.Tpo"; exit 1; fi +In file included from ../../src/utils/eoGnuplot1DSnapshot.h:38, +from ../../src/utils/checkpointing:9, +from ../../src/eo:135, +from gprop.cpp:11: +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +../../src/utils/eoFileSnapshot.h: In constructor 'eoFileSnapshot::eoFileSnapshot(std::string, unsigned int, std::string, std::string, unsigned int, bool)’: +../../src/utils/eoFileSnapshot.h:83: warning: ignoring return value of 'int system(const char*)’, declared with attribute warn_unused_result +gprop.cpp: At global scope: +gprop.cpp:37: error: conflicting declaration 'const std::string& s’ +gprop.cpp:37: error: 's’ has a previous declaration as 'mlp::set& s’ +gprop.cpp: In function 'void arg(int, char**)’: +gprop.cpp:37: error: too many arguments to function 'void load_file(mlp::set&)’ +gprop.cpp:81: error: at this point in file +gprop.cpp:37: error: too many arguments to function 'void load_file(mlp::set&)’ +gprop.cpp:82: error: at this point in file +gprop.cpp:37: error: too many arguments to function 'void load_file(mlp::set&)’ +gprop.cpp:83: error: at this point in file +make[3]: *** [gprop.o] Error 1 +make[3]: Leaving directory '/home/richel/Downloads/eo-1.0.1/app/gprop' +make[2]: *** [all-recursive] Error 1 +make[2]: Leaving directory '/home/richel/Downloads/eo-1.0.1/app' +make[1]: *** [all-recursive] Error 1 +make[1]: Leaving directory '/home/richel/Downloads/eo-1.0.1' +make: *** [all] Error 2 +``` Then, I quit trying. -  - You can download all modified EO files (up until the point I got) [here](CppEo.zip). - -  - -  - -  - -  - -  - -  - diff --git a/content/CppLocalVersusGlobal.md b/content/CppLocalVersusGlobal.md index 63a2b775..b28dcfb4 100644 --- a/content/CppLocalVersusGlobal.md +++ b/content/CppLocalVersusGlobal.md @@ -22,25 +22,15 @@ versus [global](CppGlobal.md) [variables](CppVariable.md). The following tests are performed: -- A complex calculation on only [local](CppLocal.md) - [variables](CppVariable.md) -- A complex calculation on only [member - variables](CppMemberVariable.md) -- A complex calculation on only [member - variables](CppMemberVariable.md), that are first copied to - [local](CppLocal.md) [variables](CppVariable.md). In the end of - the calculation, the [local](CppLocal.md) - [variables](CppVariable.md) are written to the [member - variables](CppMemberVariable.md) they originated from -- A complex calculation on only [global](CppGlobal.md) - [variables](CppVariable.md) +- A complex calculation on only [local](CppLocal.md) [variables](CppVariable.md) +- A complex calculation on only [member variables](CppMemberVariable.md) +- A complex calculation on only [member variables](CppMemberVariable.md), that are first copied to [local](CppLocal.md) [variables](CppVariable.md). In the end of the calculation, the [local](CppLocal.md) [variables](CppVariable.md) are written to the [member variables](CppMemberVariable.md) they originated from +- A complex calculation on only [global](CppGlobal.md) [variables](CppVariable.md)   -- [Download the Qt Creator project 'CppLocalVersusGlobal' - (version 1.2)(zip)](CppLocalVersusGlobal_1_2.zip) -- [Download the Windows executable of 'CppLocalVersusGlobal' - (version 1.0)(zip)](CppLocalVersusGlobalExe_1_0.zip) +- [Download the Qt Creator project 'CppLocalVersusGlobal' (version 1.2)(zip)](CppLocalVersusGlobal_1_2.zip) +- [Download the Windows executable of 'CppLocalVersusGlobal' (version 1.0)(zip)](CppLocalVersusGlobalExe_1_0.zip)   @@ -63,8 +53,7 @@ Technical facts [Application type(s)](CppApplication.md) -- ![Desktop](PicDesktop.png) [Desktop - application](CppDesktopApplication.md) +- ![Desktop](PicDesktop.png) [Desktop application](CppDesktopApplication.md) [Operating system(s) or programming environment(s)](CppOs.md) @@ -76,8 +65,7 @@ Technical facts [Project type](CppQtProjectType.md): -- ![console](PicConsole.png) [Console - application](CppConsoleApplication.md) +- ![console](PicConsole.png) [Console application](CppConsoleApplication.md) [C++ standard](CppStandard.md): @@ -89,8 +77,7 @@ Technical facts [Libraries](CppLibrary.md) used: -- ![STL](PicStl.png) [STL](CppStl.md): GNU ISO C++ Library, version - 4.7.2 +- ![STL](PicStl.png) [STL](CppStl.md): GNU ISO C++ Library, version 4.7.2   @@ -168,17 +155,10 @@ On a laptop (built in around 2011) with [Lubuntu](CppLubuntu.md):   -- [Andrei Alexandrescu](CppAndreiAlexandrescu.md). Modern C++ Design. - 2001. ISBN: 0201704315. Item 10: 'Minimize global and shared data'. -- [Andrei Alexandrescu](CppAndreiAlexandrescu.md). Modern C++ Design. - 2001. ISBN: 0201704315. Item 18: 'Declare variables as locally - as possible'. -- Stephen C. Dewhurst. C++ Gotchas. 2003. ISBN: 0-321-12518-5. Gotcha - \#3: 'Avoid global variables'. -- [C++ FAQ Lite](http://www.parashift.com/c++-faq/global-vars.html): - 'The names of global variables should start with //' and 'Instead of - using a global variable, you should seriously consider if there are - ways to limit the variable's visibility and/or lifetime'. +- [Andrei Alexandrescu](CppAndreiAlexandrescu.md). Modern C++ Design. 2001. ISBN: 0201704315. Item 10: 'Minimize global and shared data'. +- [Andrei Alexandrescu](CppAndreiAlexandrescu.md). Modern C++ Design. 2001. ISBN: 0201704315. Item 18: 'Declare variables as locally as possible'. +- Stephen C. Dewhurst. C++ Gotchas. 2003. ISBN: 0-321-12518-5. Gotcha \#3: 'Avoid global variables'. +- [C++ FAQ Lite](https://isocpp.org/wiki/faq/coding-standards#global-vars): 'The names of global variables should start with //' and 'Instead of using a global variable, you should seriously consider if there are ways to limit the variable's visibility and/or lifetime'.   diff --git a/content/CppMatrix.md b/content/CppMatrix.md index 36fd5b88..ccb065d9 100644 --- a/content/CppMatrix.md +++ b/content/CppMatrix.md @@ -1,23 +1,4 @@ - -  - -  - -  - -  - -  - -([C++](Cpp.md)) [Matrix](CppMatrix.md) -======================================== - -  - -![Boost](PicBoost.png)![STL](PicStl.png)![Qt -Creator](PicQtCreator.png)![Lubuntu](PicLubuntu.png) - -  +# [C++](Cpp.md)) [Matrix](CppMatrix.md) [matrix](CppMatrix.md) is a two-dimensional [container](CppContainer.md) (that is a [container](CppContainer.md) @@ -25,51 +6,26 @@ in which two values are needed to retrieve an element). For one-dimensional containers, [go to the container page](CppContainer.md). -  - There exists no std::matrix (yet). -  - Possibilities are: -1. ![C++98](PicCpp98.png)![STL](PicStl.png) - [std::vector](CppStdVector.md)<[std::vector](CppStdVector.md)<**[int](CppInt.md)**> > -2. ![C++11](PicCpp11.png)![STL](PicStl.png) - [std::array](CppStdArray.md)<[std::array](CppStdArray.md)<**[int](CppInt.md)**> > +1. ![C++98](PicCpp98.png)![STL](PicStl.png) [std::vector](CppStdVector.md)<[std::vector](CppStdVector.md)<**[int](CppInt.md)**> > +2. ![C++11](PicCpp11.png)![STL](PicStl.png) [std::array](CppStdArray.md)<[std::array](CppStdArray.md)<**[int](CppInt.md)**> > 3. ![Boost](PicBoost.png) [boost::multi\_array](CppBoostMulti_array.md) -4. ![Boost](PicBoost.png) - [boost::numeric::ublas::matrix](CppUblasMatrix.md) +4. ![Boost](PicBoost.png) [boost::numeric::ublas::matrix](CppUblasMatrix.md) 5. ![ ](PicSpacer.png)blitz::Array -6. ![ ](PicSpacer.png)[Techsoft](http://www.techsoftpl.com/matrix)'s - matrix +6. ![ ](PicSpacer.png)[Techsoft](http://www.techsoftpl.com/matrix)'s matrix 7. ![ ](PicSpacer.png)Flood::Matrix -  - These possibilities are described below in more detail. -  - -  - -  - -  - -  - -![STL](PicStl.png) [std::vector](CppStdVector.md)<[std::vector](CppStdVector.md)<**[int](CppInt.md)**> > ------------------------------------------------------------------------------------------------------------------ - -  +## ![STL](PicStl.png) [std::vector](CppStdVector.md)<[std::vector](CppStdVector.md)<**[int](CppInt.md)**> > A [std::vector](CppStdVector.md) can contain a collection of [std::vector](CppStdVector.md)s. If all [std::vector](CppStdVector.md)s in this collection are of the same size, one has a matrix. -  - When using [std::vector](CppStdVector.md)<[std::vector](CppStdVector.md)<**[int](CppInt.md)**> > for a two-dimensional matrix, the choice between x-y-ordering or @@ -81,312 +37,136 @@ in a y-x-ordered [std::vector](CppStdVector.md)<[std::vector](CppStdVector.md)<**[int](CppInt.md)**> > an individual collumn can be obtained. -  - Below is an example of a y-x-ordered [std::vector](CppStdVector.md)<[std::vector](CppStdVector.md)<**[int](CppInt.md)**> >. -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include #include int main() {   const int n_rows = 5;   const int n_cols = 10;   //Create the y-x-ordered 2D-vector   std::vector > v(n_rows, std::vector(n_cols,0),   const int y = n_rows - 1;   const int x = n_cols - 1;   assert(y < static_cast(v.size()),   assert(x < static_cast(v[y].size()),   v[y][x] = 10; //y-x-ordered }` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -  - -  - -  - -  - -  +```c++ +#include +#include + +int main() +{ + const int n_rows = 5; + const int n_cols = 10; + //Create the y-x-ordered 2D-vector + std::vector > v(n_rows, std::vector(n_cols,0), + const int y = n_rows - 1; + const int x = n_cols - 1; + assert(y < static_cast(v.size()), + assert(x < static_cast(v[y].size()), + v[y][x] = 10; //y-x-ordered +} +```  ### [std::vector](CppStdVector.md)<[std::vector](CppStdVector.md)<[int](CppInt.md)> > [code snippets](CppCodeSnippets.md) -  - Note that some of these [code snippets](CppCodeSnippets.md) also work on other [containers](CppContainer.md). -  - -1. [Convert Matrix<X> to Matrix<Y>, - ConvertMatrix](CppConvertMatrix.md) -2. [Convert std::vector<std::vector<X> > to - std::vector<std::vector<Y> >, - ConvertMatrix](CppConvertMatrix.md) -3. [Convert two 2D std::vector<X> to 2D std::vector<Y>, - ConvertMatrix](CppConvertMatrix.md) -4. [ConvertMatrix, convert Matrix<X> to - Matrix<Y>](CppConvertMatrix.md) -5. [ConvertMatrix, convert std::vector<std::vector<X> > to - std::vector<std::vector<Y> >](CppConvertMatrix.md) -6. [ConvertMatrix, convert two 2D std::vector<X> to 2D - std::vector<Y>](CppConvertMatrix.md) -7. [Get the maximal element of a 2D container, - MaxElement](CppMaxElement.md) -8. [Get the minimum element of a 2D container, - MinElement](CppMinElement.md) -9. [Get the sizes of the std::vectors in a 2D std::vector, - GetSizes](CppGetSizes.md) +1. [Convert Matrix<X> to Matrix<Y>, ConvertMatrix](CppConvertMatrix.md) +2. [Convert std::vector<std::vector<X> > to std::vector<std::vector<Y> >, ConvertMatrix](CppConvertMatrix.md) +3. [Convert two 2D std::vector<X> to 2D std::vector<Y>, ConvertMatrix](CppConvertMatrix.md) +4. [ConvertMatrix, convert Matrix<X> to Matrix<Y>](CppConvertMatrix.md) +5. [ConvertMatrix, convert std::vector<std::vector<X> > to std::vector<std::vector<Y> >](CppConvertMatrix.md) +6. [ConvertMatrix, convert two 2D std::vector<X> to 2D std::vector<Y>](CppConvertMatrix.md) +7. [Get the maximal element of a 2D container, MaxElement](CppMaxElement.md) +8. [Get the minimum element of a 2D container, MinElement](CppMinElement.md) +9. [Get the sizes of the std::vectors in a 2D std::vector, GetSizes](CppGetSizes.md) 10. [Get the sum of a 2D std::vector, GetSum](CppGetSumMatrix.md) -11. [GetSizes, get the sizes of the std::vectors in a 2D - std::vector](CppGetSizes.md) +11. [GetSizes, get the sizes of the std::vectors in a 2D std::vector](CppGetSizes.md) 12. [GetSum, get the sum of a 2D std::vector](CppGetSumMatrix.md) -13. [MaxElement, get the maximal element of a 2D - container](CppMaxElement.md) -14. [MinElement, get the minimum element of a 2D - container](CppMinElement.md) - -  - -  +13. [MaxElement, get the maximal element of a 2D container](CppMaxElement.md) +14. [MinElement, get the minimum element of a 2D container](CppMinElement.md) -  - -  - -  - -![Boost](PicBoost.png) [boost::multi\_array](CppBoostMulti_array.md) ----------------------------------------------------------------- - -  +## ![Boost](PicBoost.png) [boost::multi\_array](CppBoostMulti_array.md) The [boost::multi\_array](CppBoostMulti_array.md) (part of the [Boost](CppBoost.md) library) is not only support a two-dimensional matrix, but to many more dimensions. -  - When using [C++ Builder](CppBuilder.md) 6.0, this does not [compile](CppCompiler.md) (it results in the [compile error](CppCompileError.md) [borland.hpp: Only member functions may be 'const' or 'volatile'](CppCompileErrorBorlandHppOnlyMemberFunctionsMayBeConstOrVolatile.md)). -  - -  - -  - -  - -  - -![Boost](PicBoost.png) [boost::numeric::ublas::matrix](CppUblasMatrix.md) --------------------------------------------------------------------------- - -  +## ![Boost](PicBoost.png) [boost::numeric::ublas::matrix](CppUblasMatrix.md) The [boost::numeric::ublas::matrix](CppUblasMatrix.md) (part of the [Boost.uBLAS](CppUblas.md) [library](CppLibrary.md)) support a two-dimensional matrix. -  - See [boost::numeric::ublas::matrix](CppUblasMatrix.md). -  - -- ![OKAY](PicGreen.png)![Qt Creator](PicQtCreator.png) In [Qt - Creator](CppQtCreator.md) - [boost::numeric::ublas::matrix](CppUblasMatrix.md) works fine -- ![FAIL](PicRed.png)![C++ Builder](PicCppBuilder.png) In [C++ - Builder](CppBuilder.md) 6.0, this does not - [compile](CppCompiler.md) (it results in the [compile - error](CppCompileError.md) [Your compiler and/or configuration is - unsupported by this verions of - uBLAS](CppCompileErrorYourCompilerAndOrConfigurationIsUnsupportedByThisVerionsOfUblas.md)) - -  +- ![OKAY](PicGreen.png)![Qt Creator](PicQtCreator.png) In [Qt Creator](CppQtCreator.md) [boost::numeric::ublas::matrix](CppUblasMatrix.md) works fine +- ![FAIL](PicRed.png)![C++ Builder](PicCppBuilder.png) In [C++ Builder](CppBuilder.md) 6.0, this does not [compile](CppCompiler.md) (it results in the [compile error](CppCompileError.md) [Your compiler and/or configuration is unsupported by this verions of uBLAS](CppCompileErrorYourCompilerAndOrConfigurationIsUnsupportedByThisVerionsOfUblas.md)) -  - -  - -  - -  - -blitz::Array ------------- - -  +## blitz::Array The blitz::Array (part of the [Blitz++](CppBlitzpp.md) [library](CppLibrary.md)) is not only support a two-dimensional matrix, but to many more dimensions. -  - When using [C++ Builder](CppBuilder.md) 6.0, this does not [compile](CppCompiler.md) (it results in the [compile error](CppCompileError.md) [bzconfig.h: Unknown compiler](CppCompileErrorBzconfigHunknownCompiler.md)). -  - -  - -  - -  - -  - -[Techsoft](http://www.techsoftpl.com/matrix)'s matrix ------------------------------------------------------ - -  +## [Techsoft](http://www.techsoftpl.com/matrix)'s matrix [Techsoft](http://www.techsoftpl.com/matrix)'s matrix supports a x-y-ordered two-dimensional matrix. -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include #include int main() {   const int n_rows = 5;   const int n_cols = 10;   math::matrix v(n_rows,n_cols,   const int y = n_rows - 1;   const int x = n_cols - 1;   assert(v(x,y)==0,   v(x,y) = 10;   assert(v(x,y)==10, }` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -Flood::Matrix -------------- - -  +```c++  +#include +#include + +int main() +{ + const int n_rows = 5; + const int n_cols = 10; + math::matrix v(n_rows,n_cols, + const int y = n_rows - 1; + const int x = n_cols - 1; + assert(v(x,y)==0, + v(x,y) = 10; + assert(v(x,y)==10, +} +``` + +## Flood::Matrix The Flood::Matrix (from the [Flood](CppFlood.md) library) supports a x-y-ordered two-dimensional matrix. -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include #include   int main() {   const int n_rows = 5;   const int n_cols = 10;   Flood::Matrix v(n_rows,n_cols,   const int y = n_rows - 1;   const int x = n_cols - 1;   assert( x < v.getNumberOfRows(),   assert( y < v.getNumberOfColumns(),   assert(v[x][y]==0,   v[x][y] = 10;   assert(v[x][y]==10, }` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -External links --------------- - -  - -1. [Wikipedia page about - matrices](http://en.wikipedia.org/wiki/Matrix_%28mathematics%29) -2. [Boost page about - boost::multi\_array](http://www.boost.org/doc/libs/1_42_0/libs/multi_array/doc/index.html) +```c++ +#include +#include + +int main() +{ + const int n_rows = 5; + const int n_cols = 10; + Flood::Matrix v(n_rows,n_cols, + const int y = n_rows - 1; + const int x = n_cols - 1; + assert( x < v.getNumberOfRows(), + assert( y < v.getNumberOfColumns(), + assert(v[x][y]==0, + v[x][y] = 10; + assert(v[x][y]==10, +} +``` + +## External links + +1. [Wikipedia page about matrices](http://en.wikipedia.org/wiki/Matrix_%28mathematics%29) +2. [Boost page about boost::multi\_array](http://www.boost.org/doc/libs/1_42_0/libs/multi_array/doc/index.html) 3. [Blitz++ homepage](http://www.oonumerics.org/blitz) 4. [Techsoft homepage](http://www.techsoftpl.com/matrix) -  - -  - -  - -  - -  - -[References](CppReferences.md) -------------------------------- - -  - -1. [Wikipedia page about - matrices](http://en.wikipedia.org/wiki/Matrix_%28mathematics%29) - -Technical facts ---------------- - -  - -  - -  - -  - -  - -  - -./CppMatrix/CppMatrix.pri -------------------------- - -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` INCLUDEPATH += \     ../../Classes/CppMatrix SOURCES += \     ../../Classes/CppMatrix/matrix.cpp HEADERS  += \     ../../Classes/CppMatrix/matrix.h OTHER_FILES += \     ../../Classes/CppMatrix/Licence.txt` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppMatrix/matrix.h --------------------- - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` //--------------------------------------------------------------------------- /* Matrix, functions working on vectors and matrices Copyright 2013-2015 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppMatrix.htm //--------------------------------------------------------------------------- #ifndef MATRIX_H #define MATRIX_H #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include #include #pragma GCC diagnostic pop namespace ribi { ///Helper class for matrix operations struct Matrix {   ///Calculate the determinant   //Adapted from the code Maik Beckmann posted at   //  http://boost.2283326.n4.nabble.com/How-to-compute-determinant-td2710896.html   static double CalcDeterminant(boost::numeric::ublas::matrix m);   ///Chop returns a std::vector of sub-matrices   ///[ A at [0]   B at [1] ]   ///[ C at [2]   D at [4] ]   static const std::vector > Chop(     const boost::numeric::ublas::matrix& m);   ///Create a n_rows x n_cols sized matrix from a std::vector,   ///used for easy initialization   static boost::numeric::ublas::matrix CreateMatrix(     const std::size_t n_rows,     const std::size_t n_cols,     const std::vector& v) noexcept;   ///Create a random-filled matrix   static boost::numeric::ublas::matrix CreateRandomMatrix(     const std::size_t n_rows, const std::size_t n_cols) noexcept;   ///Create a uBLAS vector from a std::vector,   ///used for easy initialization   static boost::numeric::ublas::vector CreateVector(     const std::vector& v) noexcept;   ///Create a uBLAS vector from a std::vector,   ///used for easy initialization   static const boost::numeric::ublas::vector CreateVectorInt(     const std::vector& v) noexcept;   ///Obtain the version of this class   static std::string GetVersion() noexcept;   ///Obtain the version history of this class   static std::vector GetVersionHistory() noexcept;   ///Calculate the inverse of a matrix   static const boost::numeric::ublas::matrix Inverse(     const boost::numeric::ublas::matrix& m);   ///Check if two doubles are about equal   static bool IsAboutEqual(const double a, const double b) noexcept;   ///Check if two matrices are equal   ///This is only suitable to test for exact copies.   ///Use MatricesAreAboutEqual to allow for a   ///small difference between the matrix elements.   static bool MatricesAreEqual(     const boost::numeric::ublas::matrix& a,     const boost::numeric::ublas::matrix& b) noexcept;   ///Check if two matrices are about equal   static bool MatricesAreAboutEqual(     const boost::numeric::ublas::matrix& a,     const boost::numeric::ublas::matrix& b) noexcept;   ///Check if two matrices are about equal   static bool MatrixIsAboutEqual(     const boost::numeric::ublas::matrix& a,     const boost::numeric::ublas::matrix& b) noexcept;   ///Calculates the matrix product a * b * c   static const boost::numeric::ublas::matrix MultiProd(     const boost::numeric::ublas::matrix& a,     const boost::numeric::ublas::matrix& b,     const boost::numeric::ublas::matrix& c     );   ///Take the power of a square matrix   static const boost::numeric::ublas::matrix Power(     const boost::numeric::ublas::matrix& m,     const int exponent);   ///Calculates the matrix product a * b   ///with checking for correct dimensions   static const boost::numeric::ublas::matrix Prod(     const boost::numeric::ublas::matrix& a,     const boost::numeric::ublas::matrix& b     );   ///Calculates the matrix product a * b   ///with checking for correct dimensions   static const boost::numeric::ublas::vector Prod(     const boost::numeric::ublas::matrix& a,     const boost::numeric::ublas::vector& b     );   ///Simplify a structure   /// [ [A] ]   /// [ [B] ]    [ A ]   /// [     ]    [ B ]   /// [ [C] ]    [ C ]   /// [ [D] ] -> [ D ]   static const boost::numeric::ublas::vector SimplifyVectorOfVector(     const boost::numeric::ublas::vector<       boost::numeric::ublas::vector     >& m);   ///Simplify a structure   /// [ [A B] ]   /// [ [C D] ]    [ A B ]   /// [       ]    [ C D ]   /// [ [E F] ]    [ E F ]   /// [ [G H] ] -> [ G H ]   static const boost::numeric::ublas::matrix SimplifyVectorOfMatrix(     const boost::numeric::ublas::vector<       boost::numeric::ublas::matrix     >& m);   ///Simplify a structure   /// [ [A B]  [I J] ]   /// [ [C D]  [K L] ]    [ A B I J]   /// [              ]    [ C D K L]   /// [ [E F]  [M N] ]    [ E F M N]   /// [ [G H]  [O P] ] -> [ G H O P]   static const boost::numeric::ublas::matrix SimplifyMatrixOfMatrix(     const boost::numeric::ublas::matrix<       boost::numeric::ublas::matrix     >& m);   #ifndef NDEBUG   ///Test these functions   static void Test() noexcept;   #endif   ///Unchop merges the 4 std::vector of sub-matrices produced by Chop   static const boost::numeric::ublas::matrix Unchop(     const std::vector >& v);   ///Check if two vectors are about equal   static bool VectorsAreAboutEqual(     const boost::numeric::ublas::vector& a,     const boost::numeric::ublas::vector& b) noexcept;   ///Check if two vectors are about equal   static bool VectorIsAboutEqual(     const boost::numeric::ublas::vector& a,     const boost::numeric::ublas::vector& b) noexcept;   ///Check if two vector are equal   ///This is only suitable to test for exact copies.   ///Use VectorsAreAboutEqual to allow for a   ///small difference between the vector elements.   static bool VectorsDoubleAreEqual(     const boost::numeric::ublas::vector& a,     const boost::numeric::ublas::vector& b) noexcept;   ///Check if two vector are equal   static bool VectorsIntAreEqual(     const boost::numeric::ublas::vector& a,     const boost::numeric::ublas::vector& b) noexcept; }; } //~namespace ribi #endif // MATRIX_H` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppMatrix/matrix.cpp ----------------------- - -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` //--------------------------------------------------------------------------- /* Matrix, functions working on vectors and matrices Copyright 2013-2015 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppMatrix.htm //--------------------------------------------------------------------------- #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include "matrix.h" #include #include #include #include #include #include #include //boost::numeric::ublas::equals #pragma GCC diagnostic pop #include "ribi_random.h" #include "testtimer.h" #include "trace.h" double ribi::Matrix::CalcDeterminant(boost::numeric::ublas::matrix m) {   assert(m.size1() == m.size2() && "Can only calculate the determinant of square matrices");   boost::numeric::ublas::permutation_matrix pivots(m.size1() );   const int is_singular = boost::numeric::ublas::lu_factorize(m, pivots);   if (is_singular) return 0.0;   double d = 1.0;   const std::size_t sz = pivots.size();   for (std::size_t i=0; i != sz; ++i)   {     if (pivots(i) != i)     {       d *= -1.0;     }     d *= m(i,i);   }   return d; } const std::vector > ribi::Matrix::Chop(   const boost::numeric::ublas::matrix& m) {   using boost::numeric::ublas::range;   using boost::numeric::ublas::matrix;   using boost::numeric::ublas::matrix_range;   std::vector > v;   v.reserve(4);   const int midy = m.size1() / 2;   const int midx = m.size2() / 2;   const matrix_range > top_left(    m,range(0   ,midy     ),range(0   ,midx     ));   const matrix_range > bottom_left( m,range(midy,m.size1()),range(0   ,midx     ));   const matrix_range > top_right(   m,range(0   ,midy     ),range(midx,m.size2()));   const matrix_range > bottom_right(m,range(midy,m.size1()),range(midx,m.size2()));   v.push_back(matrix(top_left));   v.push_back(matrix(top_right));   v.push_back(matrix(bottom_left));   v.push_back(matrix(bottom_right));   return v; } boost::numeric::ublas::matrix ribi::Matrix::CreateMatrix(   const std::size_t n_rows,   const std::size_t n_cols,   const std::vector& v) noexcept {   assert(n_rows * n_cols == v.size());   boost::numeric::ublas::matrix m(n_rows,n_cols);   for (std::size_t row = 0; row!=n_rows; ++row)   {     for (std::size_t col = 0; col!=n_cols; ++col)     {       m(row,col) = v[ (col * n_rows) + row];     }   }   return m; } boost::numeric::ublas::matrix ribi::Matrix::CreateRandomMatrix(   const std::size_t n_rows, const std::size_t n_cols) noexcept {   boost::numeric::ublas::matrix m(n_rows,n_cols);   for (std::size_t row=0; row!=n_rows; ++row)   {     for (std::size_t col=0; col!=n_cols; ++col)     {       m(row,col) = Random().GetFraction();     }   }   return m; } boost::numeric::ublas::vector ribi::Matrix::CreateVector(   const std::vector& v) noexcept {   boost::numeric::ublas::vector w(v.size());   std::copy(v.begin(),v.end(),w.begin());   return w; } const boost::numeric::ublas::vector ribi::Matrix::CreateVectorInt(   const std::vector& v) noexcept {   boost::numeric::ublas::vector w(v.size());   std::copy(v.begin(),v.end(),w.begin());   return w; } std::string ribi::Matrix::GetVersion() noexcept {   return "1.3"; } std::vector ribi::Matrix::GetVersionHistory() noexcept {   return {     "2013-04-28: version 1.0: initial version",     "2013-06-11: version 1.1: fixed bugs in MatricesAreEqual and MatricesAreAboutEqual",     "2013-06-27: version 1.2: added tests, renamed VectorsAreEqual to VectorsDoubleAreEqual and VectorsIntAreEqual"     "2013-09-16: version 1.3: noexcept"   }; } const boost::numeric::ublas::matrix ribi::Matrix::Inverse(   const boost::numeric::ublas::matrix& m) {   assert(m.size1() == m.size2() && "Can only calculate the inverse of square matrices");   switch(m.size1())   {     case 0:     {       return m;     }     case 1:     {       assert(m.size1() == 1 && m.size2() == 1 && "Only for 1x1 matrices");       const double determinant = CalcDeterminant(m);       assert(determinant != 0.0);       assert(m(0,0) != 0.0 && "Cannot take the inverse of matrix [0]");       boost::numeric::ublas::matrix n(1,1);       n(0,0) =  1.0 / determinant;       return n;     }     case 2:     {       assert(m.size1() == 2 && m.size2() == 2 && "Only for 2x2 matrices");       const double determinant = CalcDeterminant(m);       assert(determinant != 0.0);       const double a = m(0,0);       const double b = m(0,1);       const double c = m(1,0);       const double d = m(1,1);       boost::numeric::ublas::matrix n(2,2);       n(0,0) =  d / determinant;       n(0,1) = -b / determinant;       n(1,0) = -c / determinant;       n(1,1) =  a / determinant;       return n;     }     case 3:     {       assert(m.size1() == 3 && m.size2() == 3 && "Only for 3x3 matrices");       const double determinant = CalcDeterminant(m);       assert(determinant != 0.0);       const double a = m(0,0);       const double b = m(0,1);       const double c = m(0,2);       const double d = m(1,0);       const double e = m(1,1);       const double f = m(1,2);       const double g = m(2,0);       const double h = m(2,1);       const double k = m(2,2);       boost::numeric::ublas::matrix n(3,3);       const double new_a =  ((e*k)-(f*h)) / determinant;       const double new_b = -((d*k)-(f*g)) / determinant;       const double new_c =  ((d*h)-(e*g)) / determinant;       const double new_d = -((b*k)-(c*h)) / determinant;       const double new_e =  ((a*k)-(c*g)) / determinant;       const double new_f = -((a*h)-(b*g)) / determinant;       const double new_g =  ((b*f)-(c*e)) / determinant;       const double new_h = -((a*f)-(c*d)) / determinant;       const double new_k =  ((a*e)-(b*d)) / determinant;       n(0,0) = new_a;       n(1,0) = new_b;       n(2,0) = new_c;       n(0,1) = new_d;       n(1,1) = new_e;       n(2,1) = new_f;       n(0,2) = new_g;       n(1,2) = new_h;       n(2,2) = new_k;       return n;     }     default:     {       //Use blockwise inversion       //ribi::Matrix::Chop returns a std::vector       //[ A at [0]   B at [1] ]       //[ C at [2]   D at [4] ]       assert(m.size1() > 3);       assert(m.size2() > 3);       const std::vector > v = Chop(m);       const boost::numeric::ublas::matrix& a = v[0];       assert(a.size1() == a.size2());       const boost::numeric::ublas::matrix  a_inv = Inverse(a);       const boost::numeric::ublas::matrix& b = v[1];       const boost::numeric::ublas::matrix& c = v[2];       const boost::numeric::ublas::matrix& d = v[3];       const boost::numeric::ublas::matrix term         = d         - ribi::Matrix::Prod(             boost::numeric::ublas::matrix(ribi::Matrix::Prod(c,a_inv)),             b           );       assert(term.size1() == term.size2());       const boost::numeric::ublas::matrix term_inv = Inverse(term);       const boost::numeric::ublas::matrix new_a         = a_inv         + boost::numeric::ublas::matrix(ribi::Matrix::Prod(             boost::numeric::ublas::matrix(ribi::Matrix::Prod(               boost::numeric::ublas::matrix(ribi::Matrix::Prod(                 boost::numeric::ublas::matrix(ribi::Matrix::Prod(                   a_inv,                   b)),                 term_inv)),              c)),             a_inv));       const boost::numeric::ublas::matrix new_b         =         - boost::numeric::ublas::matrix(ribi::Matrix::Prod(             boost::numeric::ublas::matrix(ribi::Matrix::Prod(               a_inv,               b)),             term_inv));       const boost::numeric::ublas::matrix new_c         =         - boost::numeric::ublas::matrix(ribi::Matrix::Prod(             boost::numeric::ublas::matrix(ribi::Matrix::Prod(               term_inv,               c)),             a_inv));       const boost::numeric::ublas::matrix new_d = term_inv;       const std::vector > w = { new_a, new_b, new_c, new_d };       const boost::numeric::ublas::matrix result = Unchop(w);       return result;     }   } } bool ribi::Matrix::IsAboutEqual(const double a, const double b) noexcept {   const double epsilon = 0.000001; //Rounding error   return a - epsilon < b && a + epsilon > b; } const boost::numeric::ublas::matrix ribi::Matrix::Power(   const boost::numeric::ublas::matrix& m,   const int exponent) {   assert(exponent >= 0 && "Can only take the power of matrices with a positive exponent");   assert(m.size1() == m.size2() && "Can only take the power of square matrices");   const std::size_t sz = m.size1();   if (exponent == 0) return boost::numeric::ublas::identity_matrix(sz);   if (exponent == 1) return m;   boost::numeric::ublas::matrix n(m);   for (int i=1; i!=exponent; ++i)   {     n = ribi::Matrix::Prod(n,m);   }   return n; } bool ribi::Matrix::MatricesAreAboutEqual(   const boost::numeric::ublas::matrix& a,   const boost::numeric::ublas::matrix& b) noexcept {   if (a.size1() != b.size1()) return false;   if (a.size2() != b.size2()) return false;   //return std::equal(a.begin1(),a.end1(),b.begin1(),&ribi::Matrix::IsAboutEqual); //DON'T USE STD::EQUAL!   assert(a.size1() == b.size1());   assert(a.size2() == b.size2());   const std::size_t n_rows = a.size1();   const std::size_t n_cols = a.size2();   for (std::size_t row = 0; row != n_rows; ++row)   {     for (std::size_t col = 0; col != n_cols; ++col)     {       if (!IsAboutEqual(a(row,col),b(row,col))) return false;     }   }   return true; } bool ribi::Matrix::MatricesAreEqual(   const boost::numeric::ublas::matrix& a,   const boost::numeric::ublas::matrix& b) noexcept {   if ( a.size1() != b.size1()     || a.size2() != b.size2()) return false;   //const bool is_equal = std::equal(a.begin1(),a.end1(),b.begin1()); //DON'T USE STD::EQUAL!   assert(a.size1() == b.size1());   assert(a.size2() == b.size2());   const std::size_t n_rows = a.size1();   const std::size_t n_cols = a.size2();   for (std::size_t row = 0; row != n_rows; ++row)   {     for (std::size_t col = 0; col != n_cols; ++col)     {       if (a(row,col) != b(row,col)) return false;     }   }   return true; } bool ribi::Matrix::MatrixIsAboutEqual(   const boost::numeric::ublas::matrix& a,   const boost::numeric::ublas::matrix& b) noexcept {   TRACE("Deprecated naming");   return MatricesAreAboutEqual(a,b); } const boost::numeric::ublas::matrix ribi::Matrix::MultiProd(   const boost::numeric::ublas::matrix& a,   const boost::numeric::ublas::matrix& b,   const boost::numeric::ublas::matrix& c) {   return Prod(Prod(a,b),c); } const boost::numeric::ublas::matrix ribi::Matrix::Prod(   const boost::numeric::ublas::matrix& a,   const boost::numeric::ublas::matrix& b   ) {   assert(a.size2() == b.size1() && "A's width must be B's height");   return boost::numeric::ublas::prod(a,b); } const boost::numeric::ublas::vector ribi::Matrix::Prod(   const boost::numeric::ublas::matrix& a,   const boost::numeric::ublas::vector& b   ) {   assert(a.size2() == b.size() && "A's width must be B's height");   return boost::numeric::ublas::prod(a,b); } const boost::numeric::ublas::matrix ribi::Matrix::SimplifyMatrixOfMatrix(   const boost::numeric::ublas::matrix >& m) {   // [ [A B]  [I J] ]   // [ [C D]  [K L] ]    [ A B I J]   // [              ]    [ C D K L]   // [ [E F]  [M N] ]    [ E F M N]   // [ [G H]  [O P] ] -> [ G H O P]   //assert(m.size1() > 0);   //assert(m.size2() > 0);   //   const int n_sub_rows = boost::numeric_cast(m.size1());   const int n_sub_cols = boost::numeric_cast(m.size2());   const int sub_rows   = n_sub_rows != 0 && n_sub_cols != 0 ? boost::numeric_cast(m(0,0).size1()) : 0;   const int sub_cols   = n_sub_cols != 0 && n_sub_cols != 0 ? boost::numeric_cast(m(0,0).size2()) : 0;   boost::numeric::ublas::matrix v(n_sub_rows * sub_rows, n_sub_cols * sub_cols);   for (int sub_row=0; sub_row!=n_sub_rows; ++sub_row)   {     for (int sub_col=0; sub_col!=n_sub_cols; ++sub_col)     {       assert(sub_row < boost::numeric_cast(m.size1()));       assert(sub_col < boost::numeric_cast(m.size2()));       const boost::numeric::ublas::matrix& sub = m(sub_row,sub_col);       const int offset_x = sub_col * sub_cols;       const int offset_y = sub_row * sub_rows;       for (int row=0; row!=sub_rows; ++row)       {         for (int col=0; col!=sub_cols; ++col)         {           assert(offset_y + row < boost::numeric_cast(v.size1()));           assert(offset_x + col < boost::numeric_cast(v.size2()));           assert(row < boost::numeric_cast(sub.size1()));           assert(col < boost::numeric_cast(sub.size2()));           v(offset_y + row,offset_x + col) = sub(row,col);         }       }     }   }   //   return v; } const boost::numeric::ublas::matrix ribi::Matrix::SimplifyVectorOfMatrix(   const boost::numeric::ublas::vector >& m) {   // [ [A B] ]   // [ [C D] ]    [ A B ]   // [       ]    [ C D ]   // [ [E F] ]    [ E F ]   // [ [G H] ] -> [ G H ]   assert(!m.empty());   const int n_subs   = boost::numeric_cast(m.size());   const int sub_rows = boost::numeric_cast(m[0].size1());   const int sub_cols = boost::numeric_cast(m[0].size2());   boost::numeric::ublas::matrix v(n_subs * sub_rows, sub_cols);   for (int sub_index=0; sub_index!=n_subs; ++sub_index)   {     assert(sub_index < boost::numeric_cast(m.size()));     const boost::numeric::ublas::matrix& sub = m[sub_index];     const int offset_x = 0;     const int offset_y = sub_index * sub_rows;     for (int row=0; row!=sub_rows; ++row)     {       for (int col=0; col!=sub_cols; ++col)       {         assert(offset_y + row < boost::numeric_cast(v.size1()));         assert(offset_x + col < boost::numeric_cast(v.size2()));         assert(row < boost::numeric_cast(sub.size1()));         assert(col < boost::numeric_cast(sub.size2()));         v(offset_y + row,offset_x + col) = sub(row,col);       }     }   }   return v; } const boost::numeric::ublas::vector ribi::Matrix::SimplifyVectorOfVector(   const boost::numeric::ublas::vector >& m) {   // [ [A] ]   // [ [B] ]    [ A ]   // [     ]    [ B ]   // [ [C] ]    [ C ]   // [ [D] ] -> [ D ]   //assert(!m.empty());   const int n_subs = boost::numeric_cast(m.size());   const int subs_sz = n_subs > 0 ? boost::numeric_cast(m[0].size()) : 0;   boost::numeric::ublas::vector v(n_subs * subs_sz);   for (int i=0; i!=n_subs; ++i)   {     assert(i < boost::numeric_cast(m.size()));     const boost::numeric::ublas::vector& sub = m[i];     std::copy(sub.begin(),sub.end(),v.begin() + (i * subs_sz));   }   return v; } #ifndef NDEBUG void ribi::Matrix::Test() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     Random();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   using boost::numeric::ublas::detail::equals;   using boost::numeric::ublas::matrix;   using boost::numeric::ublas::vector;   //Test CreateMatrix   {     // [1,4]     // [2,5]     // [3,6]     const matrix m = CreateMatrix(3,2, {1,2,3,4,5,6} );     assert(m(0,0) == 1);     assert(m(1,0) == 2);     assert(m(2,0) == 3);     assert(m(0,1) == 4);     assert(m(1,1) == 5);     assert(m(2,1) == 6);   }   //Simplify vector of vector   {     /// [ [A] ]     /// [ [B] ]    [ A ]     /// [     ]    [ B ]     /// [ [C] ]    [ C ]     /// [ [D] ] -> [ D ]     boost::numeric::ublas::vector > v(2);     v[0] = CreateVector( { 1.0, 2.0 } );     v[1] = CreateVector( { 3.0, 4.0 } );     const boost::numeric::ublas::vector w       = SimplifyVectorOfVector(v);     assert(w.size() == 4);     assert(VectorsAreAboutEqual(w, CreateVector( { 1.0, 2.0, 3.0, 4.0 } )));   }   {     ///Simplify a structure     /// [ [A B] ]     /// [ [C D] ]    [ A B ]     /// [       ]    [ C D ]     /// [ [E F] ]    [ E F ]     /// [ [G H] ] -> [ G H ]     boost::numeric::ublas::vector > v(2);     v[0] = CreateMatrix(2,2, {1.0, 3.0, 2.0, 4.0} );     v[1] = CreateMatrix(2,2, {5.0, 7.0, 6.0, 8.0} );     const boost::numeric::ublas::matrix w       = SimplifyVectorOfMatrix(v);     assert(w.size1() == 4);     assert(w.size2() == 2);     assert(MatricesAreAboutEqual(w, CreateMatrix(4,2, { 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 } )));   }   {     //Simplify a structure     // [ [A B]  [I J] ]     // [ [C D]  [K L] ]    [ A B I J]     // [              ]    [ C D K L]     // [ [E F]  [M N] ]    [ E F M N]     // [ [G H]  [O P] ] -> [ G H O P]     // [ [ 1  2]  [ 3  4] ]     // [ [ 5  6]  [ 7  8] ]    [ A B I J]     // [                  ]    [ C D K L]     // [ [ 9 10]  [11 12] ]    [ E F M N]     // [ [13 14]  [15 16] ] -> [ G H O P]     boost::numeric::ublas::matrix > v(2,2);     v(0,0) = CreateMatrix(2,2, { 1.0,  5.0,  2.0,  6.0} );     v(1,0) = CreateMatrix(2,2, { 9.0, 13.0, 10.0, 14.0} );     v(0,1) = CreateMatrix(2,2, { 3.0,  7.0,  4.0,  8.0} );     v(1,1) = CreateMatrix(2,2, {11.0, 15.0, 12.0, 16.0} );     const boost::numeric::ublas::matrix w       = SimplifyMatrixOfMatrix(v);     assert(w.size1() == 4);     assert(w.size2() == 4);     const boost::numeric::ublas::matrix expected       = CreateMatrix(4,4,       {         1.0, 5.0,  9.0, 13.0,         2.0, 6.0, 10.0, 14.0,         3.0, 7.0, 11.0, 15.0,         4.0, 8.0, 12.0, 16.0       } );     if (!MatricesAreAboutEqual(w,expected))     {       std::cerr         << "w: " << w << '\n'         << "e: " << expected << '\n';     }     assert(MatricesAreAboutEqual(w,expected));   }   //Test Chop on 3x3   {     //                     [ 1.0 ] | [ 2.0   3.0 ]     // [ 1.0 2.0 3.0 ]     --------+--------------     // [ 4.0 5.0 6.0 ]     [ 4.0 ] | [ 5.0   6.0 ]     // [ 7.0 8.0 9.0 ] ->  [ 7.0 ] | [ 8.0   9.0 ]     const matrix m = CreateMatrix(3,3, {1.0,4.0,7.0,2.0,5.0,8.0,3.0,6.0,9.0} );     assert(m(0,0) == 1.0); assert(m(0,1) == 2.0); assert(m(0,2) == 3.0);     assert(m(1,0) == 4.0); assert(m(1,1) == 5.0); assert(m(1,2) == 6.0);     assert(m(2,0) == 7.0); assert(m(2,1) == 8.0); assert(m(2,2) == 9.0);     const std::vector > n = Chop(m);     assert(n.size() == 4);     assert(n[0].size1() == 1);     assert(n[0].size2() == 1);     assert(n[1].size1() == 1);     assert(n[1].size2() == 2);     assert(n[2].size1() == 2);     assert(n[2].size2() == 1);     assert(n[3].size1() == 2);     assert(n[3].size2() == 2);     assert(n[0].size1() + n[2].size1() == m.size1());     assert(n[1].size1() + n[3].size1() == m.size1());     assert(n[0].size2() + n[1].size2() == m.size2());     assert(n[2].size2() + n[3].size2() == m.size2());   }   //Test Chop on 5x5   {     const matrix m = CreateMatrix(5,5,       {         1.0, 6.0,11.0,16.0,21.0,         2.0, 7.0,12.0,17.0,22.0,         3.0, 8.0,13.0,18.0,23.0,         4.0, 9.0,14.0,19.0,24.0,         5.0,10.0,15.0,20.0,25.0       }     );     assert(m(0,0) ==  1.0); assert(m(0,1) ==  2.0); assert(m(0,2) ==  3.0); assert(m(0,3) ==  4.0); assert(m(0,4) ==  5.0);     assert(m(1,0) ==  6.0); assert(m(1,1) ==  7.0); assert(m(1,2) ==  8.0); assert(m(1,3) ==  9.0); assert(m(1,4) == 10.0);     assert(m(2,0) == 11.0); assert(m(2,1) == 12.0); assert(m(2,2) == 13.0); assert(m(2,3) == 14.0); assert(m(2,4) == 15.0);     assert(m(3,0) == 16.0); assert(m(3,1) == 17.0); assert(m(3,2) == 18.0); assert(m(3,3) == 19.0); assert(m(3,4) == 20.0);     assert(m(4,0) == 21.0); assert(m(4,1) == 22.0); assert(m(4,2) == 23.0); assert(m(4,3) == 24.0); assert(m(4,4) == 25.0);     const std::vector > n = Chop(m);     assert(n.size() == 4);     assert(n[0].size1() == 2);     assert(n[0].size2() == 2);     assert(n[1].size1() == 2);     assert(n[1].size2() == 3);     assert(n[2].size1() == 3);     assert(n[2].size2() == 2);     assert(n[3].size1() == 3);     assert(n[3].size2() == 3);     assert(n[0].size1() + n[2].size1() == m.size1());     assert(n[1].size1() + n[3].size1() == m.size1());     assert(n[0].size2() + n[1].size2() == m.size2());     assert(n[2].size2() + n[3].size2() == m.size2());   }   //Test VectorsAreAboutEqual   {     const vector m = CreateVector( {1.0,3.0,2.0,4.0} );     assert(VectorsAreAboutEqual(m,m));     vector n(m);     n *= 3.0;     n /= 6.0;     n *= 2.0;     assert(VectorsAreAboutEqual(m,n));   }   //Test Power   {     const int sz = 2;     const matrix m = CreateMatrix(sz,sz, {1.0,3.0,2.0,4.0} );     const matrix expected_0 = boost::numeric::ublas::identity_matrix(sz);     const matrix expected_1 = m;     const matrix expected_2 = CreateMatrix(sz,sz, {7.0,15.0,10.0,22.0} );     assert(ribi::Matrix::MatricesAreAboutEqual(m,m));     assert(ribi::Matrix::MatricesAreAboutEqual(Power(m,0),expected_0));     assert(ribi::Matrix::MatricesAreAboutEqual(Power(m,1),expected_1));     assert(ribi::Matrix::MatricesAreAboutEqual(Power(m,2),expected_2));   }   //Test Unchop   {     //Check 0x0 to and including 9x9 matrices     for (std::size_t n_rows = 0; n_rows!=10; ++n_rows)     {       for (std::size_t n_cols = 0; n_cols!=10; ++n_cols)       {         //Epsilon is more or less the smallest round-off error         const double epsilon = std::numeric_limits::epsilon();         //Create a random matrix         const matrix m = ribi::Matrix::CreateRandomMatrix(n_rows,n_cols);         //Assume it is found identical to itself         assert(equals(m,m,epsilon,epsilon));         //Chop and unchop the input matrix         const matrix n = ribi::Matrix::Unchop(Chop(m));         //Assume input matrix and result are identical         assert(equals(m,n,epsilon,epsilon));       }     }   }   //Test Inverse on 2x2 matrix   {     // [ 1.0 2.0 ] -1    [ -2.0   1.0 ]     // [ 3.0 4.0 ]     = [  1.5  -0.5 ]     const matrix m = ribi::Matrix::CreateMatrix(2,2, {1.0,3.0,2.0,4.0} );     assert(m(0,0) == 1.0);     assert(m(1,0) == 3.0);     assert(m(0,1) == 2.0);     assert(m(1,1) == 4.0);     const matrix n = ribi::Matrix::Inverse(m);     const double epsilon = 0.0000001; //Rounding error     assert(n(0,0) > -2.0 - epsilon && n(0,0) < -2.0 + epsilon);     assert(n(1,0) >  1.5 - epsilon && n(1,0) <  1.5 + epsilon);     assert(n(0,1) >  1.0 - epsilon && n(0,1) <  1.0 + epsilon);     assert(n(1,1) > -0.5 - epsilon && n(1,1) < -0.5 + epsilon);     assert(ribi::Matrix::Prod(m,n)(0,0) > 1.0 - epsilon && ribi::Matrix::Prod(m,n)(0,0) < 1.0 + epsilon);     assert(ribi::Matrix::Prod(m,n)(1,0) > 0.0 - epsilon && ribi::Matrix::Prod(m,n)(1,0) < 0.0 + epsilon);     assert(ribi::Matrix::Prod(m,n)(0,1) > 0.0 - epsilon && ribi::Matrix::Prod(m,n)(0,1) < 0.0 + epsilon);     assert(ribi::Matrix::Prod(m,n)(1,1) > 1.0 - epsilon && ribi::Matrix::Prod(m,n)(1,1) < 1.0 + epsilon);   }   {     // [ 1.0 2.0 3.0] -1    [ -24.0   18.0   5.0]     // [ 0.0 1.0 4.0]       [  20.0  -15.0  -4.0]     // [ 5.0 6.0 0.0]     = [ - 5.0    4.0   1.0]     const matrix m = ribi::Matrix::CreateMatrix(3,3, {1.0,0.0,5.0,2.0,1.0,6.0,3.0,4.0,0.0} );     assert(m(0,0) == 1.0); assert(m(0,1) == 2.0); assert(m(0,2) == 3.0);     assert(m(1,0) == 0.0); assert(m(1,1) == 1.0); assert(m(1,2) == 4.0);     assert(m(2,0) == 5.0); assert(m(2,1) == 6.0); assert(m(2,2) == 0.0);     const matrix n = ribi::Matrix::Inverse(m);     const double epsilon = 0.0001; //Rounding error     assert(n(0,0) > -24.0 - epsilon && n(0,0) < -24.0 + epsilon);     assert(n(1,0) >  20.0 - epsilon && n(1,0) <  20.0 + epsilon);     assert(n(2,0) > - 5.0 - epsilon && n(2,0) < - 5.0 + epsilon);     assert(n(0,1) >  18.0 - epsilon && n(0,1) <  18.0 + epsilon);     assert(n(1,1) > -15.0 - epsilon && n(1,1) < -15.0 + epsilon);     assert(n(2,1) >   4.0 - epsilon && n(2,1) <   4.0 + epsilon);     assert(n(0,2) >   5.0 - epsilon && n(0,2) <   5.0 + epsilon);     assert(n(1,2) >  -4.0 - epsilon && n(1,2) < - 4.0 + epsilon);     assert(n(2,2) >   1.0 - epsilon && n(2,2) <   1.0 + epsilon);     const matrix i = ribi::Matrix::Prod(m,n);     assert(i(0,0) > 1.0 - epsilon && i(0,0) < 1.0 + epsilon);     assert(i(1,0) > 0.0 - epsilon && i(1,0) < 0.0 + epsilon);     assert(i(2,0) > 0.0 - epsilon && i(2,0) < 0.0 + epsilon);     assert(i(0,1) > 0.0 - epsilon && i(0,1) < 0.0 + epsilon);     assert(i(1,1) > 1.0 - epsilon && i(1,1) < 1.0 + epsilon);     assert(i(2,1) > 0.0 - epsilon && i(2,1) < 0.0 + epsilon);     assert(i(0,2) > 0.0 - epsilon && i(0,2) < 0.0 + epsilon);     assert(i(1,2) > 0.0 - epsilon && i(1,2) < 0.0 + epsilon);     assert(i(2,2) > 1.0 - epsilon && i(2,2) < 1.0 + epsilon);   }   //Test Inverse on 3x3 matrix   {     // [ 1.0 2.0 3.0] -1     // [ 4.0 4.0 6.0]     // [ 7.0 8.0 9.0]     // Note: cannot make the center value equal to 5.0, as this makes     // the matrix un-invertible (the determinant becomes equal to zero)     const matrix m = ribi::Matrix::CreateMatrix(3,3, {1.0,4.0,7.0,2.0,4.0,8.0,3.0,6.0,9.0} );     assert(m(0,0) == 1.0); assert(m(0,1) == 2.0); assert(m(0,2) == 3.0);     assert(m(1,0) == 4.0); assert(m(1,1) == 4.0); assert(m(1,2) == 6.0);     assert(m(2,0) == 7.0); assert(m(2,1) == 8.0); assert(m(2,2) == 9.0);     const matrix n = ribi::Matrix::Inverse(m);     const double epsilon = 0.00001; //Rounding error     const matrix i = ribi::Matrix::Prod(m,n);     assert(i(0,0) > 1.0 - epsilon && i(0,0) < 1.0 + epsilon);     assert(i(1,0) > 0.0 - epsilon && i(1,0) < 0.0 + epsilon);     assert(i(2,0) > 0.0 - epsilon && i(2,0) < 0.0 + epsilon);     assert(i(0,1) > 0.0 - epsilon && i(0,1) < 0.0 + epsilon);     assert(i(1,1) > 1.0 - epsilon && i(1,1) < 1.0 + epsilon);     assert(i(2,1) > 0.0 - epsilon && i(2,1) < 0.0 + epsilon);     assert(i(0,2) > 0.0 - epsilon && i(0,2) < 0.0 + epsilon);     assert(i(1,2) > 0.0 - epsilon && i(1,2) < 0.0 + epsilon);     assert(i(2,2) > 1.0 - epsilon && i(2,2) < 1.0 + epsilon);   }   //Test Inverse on 4x4 matrix   {     const matrix m = ribi::Matrix::CreateRandomMatrix(4,4);     const matrix n = ribi::Matrix::Inverse(m);     const double epsilon = 0.00001; //Rounding error     const matrix i = ribi::Matrix::Prod(m,n);     //Test if i is identity matrix     assert(i(0,0) > 1.0 - epsilon && i(0,0) < 1.0 + epsilon);     assert(i(1,0) > 0.0 - epsilon && i(1,0) < 0.0 + epsilon);     assert(i(2,0) > 0.0 - epsilon && i(2,0) < 0.0 + epsilon);     assert(i(3,0) > 0.0 - epsilon && i(3,0) < 0.0 + epsilon);     assert(i(0,1) > 0.0 - epsilon && i(0,1) < 0.0 + epsilon);     assert(i(1,1) > 1.0 - epsilon && i(1,1) < 1.0 + epsilon);     assert(i(2,1) > 0.0 - epsilon && i(2,1) < 0.0 + epsilon);     assert(i(3,1) > 0.0 - epsilon && i(3,1) < 0.0 + epsilon);     assert(i(0,2) > 0.0 - epsilon && i(0,2) < 0.0 + epsilon);     assert(i(1,2) > 0.0 - epsilon && i(1,2) < 0.0 + epsilon);     assert(i(2,2) > 1.0 - epsilon && i(2,2) < 1.0 + epsilon);     assert(i(3,2) > 0.0 - epsilon && i(3,2) < 0.0 + epsilon);     assert(i(0,3) > 0.0 - epsilon && i(0,3) < 0.0 + epsilon);     assert(i(1,3) > 0.0 - epsilon && i(1,3) < 0.0 + epsilon);     assert(i(2,3) > 0.0 - epsilon && i(2,3) < 0.0 + epsilon);     assert(i(3,3) > 1.0 - epsilon && i(3,3) < 1.0 + epsilon);   }   //TRACE("Test Inverse on bigger matrices");   for (std::size_t sz = 5; sz!=20; ++sz)   {     const matrix m = ribi::Matrix::CreateRandomMatrix(sz,sz);     const matrix n = ribi::Matrix::Inverse(m);     const double epsilon = 0.00001; //Rounding error     const matrix i = ribi::Matrix::Prod(m,n);     //Test if i is identity matrix     for (std::size_t y = 0; y!=sz; ++y)     {       for (std::size_t x = 0; x!=sz; ++x)       {         assert(              (x == y && i(y,x) > 1.0 - epsilon && i(y,x) < 1.0 + epsilon)           || (x != y && i(y,x) > 0.0 - epsilon && i(y,x) < 0.0 + epsilon)         );       }     }   }   //TRACE("Test MatricesAreEqual");   {     {       const auto a = boost::numeric::ublas::zero_matrix(2,3);       const auto b = boost::numeric::ublas::zero_matrix(3,2);       const auto c = boost::numeric::ublas::zero_matrix(2,2);       const auto d = boost::numeric::ublas::zero_matrix(3,3);       assert( MatricesAreEqual(a,a));       assert( MatricesAreEqual(b,b));       assert( MatricesAreEqual(c,c));       assert( MatricesAreEqual(d,d));       assert(!MatricesAreEqual(a,b));       assert(!MatricesAreEqual(a,c));       assert(!MatricesAreEqual(a,d));       assert(!MatricesAreEqual(b,c));       assert(!MatricesAreEqual(b,d));       assert(!MatricesAreEqual(c,d));     }     {       const auto a = CreateMatrix(2,2, { 1.0,0.0,0.0,1.0 } );       auto b = a;       assert(MatricesAreEqual(a,b));       assert(MatricesAreAboutEqual(a,b));       b(1,1) = 0.0;       assert(!MatricesAreEqual(a,b));       assert(!MatricesAreAboutEqual(a,b));       b(1,1) = 1.0;       assert(MatricesAreEqual(a,b));       assert(MatricesAreAboutEqual(a,b));     }   }   //TRACE("Test VectorsAreEqual (int)");   {     {       const auto a = boost::numeric::ublas::vector(2,0);       const auto b = boost::numeric::ublas::vector(3,0);       assert( VectorsIntAreEqual(a,a));       assert( VectorsIntAreEqual(b,b));       assert(!VectorsIntAreEqual(a,b));       assert(!VectorsIntAreEqual(b,a));     }     {       const auto a = CreateVector( { 1,2,3 } );       auto b = a;       assert(VectorsIntAreEqual(a,a));       assert(VectorsIntAreEqual(a,b));       assert(VectorsIntAreEqual(b,a));       assert(VectorsIntAreEqual(b,b));       b(1) = 0;       assert( VectorsIntAreEqual(a,a));       assert(!VectorsIntAreEqual(a,b));       assert(!VectorsIntAreEqual(b,a));       assert( VectorsIntAreEqual(b,b));       b(1) = 2;       assert(VectorsIntAreEqual(a,a));       assert(VectorsIntAreEqual(a,b));       assert(VectorsIntAreEqual(b,a));       assert(VectorsIntAreEqual(b,b));     }   }   //TRACE("Test VectorsAreEqual (double)");   {     {       const auto a = boost::numeric::ublas::zero_vector(2);       const auto b = boost::numeric::ublas::zero_vector(3);       assert( VectorsDoubleAreEqual(a,a));       assert( VectorsDoubleAreEqual(b,b));       assert(!VectorsDoubleAreEqual(a,b));       assert(!VectorsDoubleAreEqual(b,a));     }     {       const auto a = CreateVector( { 1.1,2.2,3.3 } );       auto b = a;       assert(VectorsDoubleAreEqual(a,b));       assert(VectorsAreAboutEqual(a,b));       b(1) = 0.0;       assert(!VectorsDoubleAreEqual(a,b));       assert(!VectorsAreAboutEqual(a,b));       b(1) = 2.2;       assert(VectorsDoubleAreEqual(a,b));       assert(VectorsAreAboutEqual(a,b));     }   } } #endif const boost::numeric::ublas::matrix ribi::Matrix::Unchop(   const std::vector >& v) {   //Chop returns a std::vector of sub-matrices   //[ A at [0]   B at [1] ]   //[ C at [2]   D at [4] ]   using boost::numeric::ublas::range;   using boost::numeric::ublas::matrix;   using boost::numeric::ublas::matrix_range;   assert(v.size() == 4);   assert(v[0].size1() == v[1].size1());   assert(v[2].size1() == v[3].size1());   assert(v[0].size2() == v[2].size2());   assert(v[1].size2() == v[3].size2());   boost::numeric::ublas::matrix m(v[0].size1() + v[2].size1(),v[0].size2() + v[1].size2());   for (int quadrant=0; quadrant!=4; ++quadrant)   {     const boost::numeric::ublas::matrix& w = v[quadrant];     const std::size_t n_rows = v[quadrant].size1();     const std::size_t n_cols = v[quadrant].size2();     const int offset_x = quadrant % 2 ? v[0].size2() : 0;     const int offset_y = quadrant / 2 ? v[0].size1() : 0;     for (std::size_t row=0; row!=n_rows; ++row)     {       for (std::size_t col=0; col!=n_cols; ++col)       {         m(offset_y + row, offset_x + col) = w(row,col);       }     }   }   assert(v[0].size1() + v[2].size1() == m.size1());   assert(v[1].size1() + v[3].size1() == m.size1());   assert(v[0].size2() + v[1].size2() == m.size2());   assert(v[2].size2() + v[3].size2() == m.size2());   return m; } bool ribi::Matrix::VectorIsAboutEqual(   const boost::numeric::ublas::vector& a,   const boost::numeric::ublas::vector& b) noexcept {   TRACE("Deprecated naming");   return VectorsAreAboutEqual(a,b); } bool ribi::Matrix::VectorsAreAboutEqual(   const boost::numeric::ublas::vector& a,   const boost::numeric::ublas::vector& b) noexcept {   if (a.size() != b.size()) return false;   return std::equal(a.begin(),a.end(),b.begin(),&ribi::Matrix::IsAboutEqual); } bool ribi::Matrix::VectorsDoubleAreEqual(   const boost::numeric::ublas::vector& a,   const boost::numeric::ublas::vector& b) noexcept {   if (a.size() != b.size()) return false;   return std::equal(a.begin(),a.end(),b.begin()); } bool ribi::Matrix::VectorsIntAreEqual(   const boost::numeric::ublas::vector& a,   const boost::numeric::ublas::vector& b) noexcept {   if (a.size() != b.size()) return false;   return std::equal(a.begin(),a.end(),b.begin()); }` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -  +## [References](CppReferences.md) +1. [Wikipedia page about matrices](http://en.wikipedia.org/wiki/Matrix_%28mathematics%29) diff --git a/content/CppQtCreatorProFile.md b/content/CppQtCreatorProFile.md index 3936e8b9..d68b5390 100644 --- a/content/CppQtCreatorProFile.md +++ b/content/CppQtCreatorProFile.md @@ -1,141 +1,3 @@ +# QtCreatorProFile -  - -  - -  - -  - -  - -([C++](Cpp.md)) [QtCreatorProFile](CppQtCreatorProFile.md) -============================================================ - -  - -![STL](PicStl.png)![Qt -Creator](PicQtCreator.png)![Lubuntu](PicLubuntu.png) - -  - -[QtCreatorProFile](CppQtCreatorProFile.md) is a [Qt project file -(.pro)](CppQtProjectFile.md) [class](CppClass.md). - -  - -[QtCreatorProFile](CppQtCreatorProFile.md) is tested by the -[tool](https://github.com/richelbilderbeek/tools) [TestQtCreatorProFile](https://github.com/richelbilderbeek/TestQtCreatorProFile). - -Technical facts ---------------- - -  - -  - -  - -  - -  - -  - -./CppQtCreatorProFile/CppQtCreatorProFile.pri ---------------------------------------------- - -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` INCLUDEPATH += \     ../../Classes/CppQtCreatorProFile SOURCES += \     ../../Classes/CppQtCreatorProFile/qtcreatorprofile.cpp \     ../../Classes/CppQtCreatorProFile/qtcreatorprofilezipscript.cpp HEADERS  += \     ../../Classes/CppQtCreatorProFile/qtcreatorprofile.h \     ../../Classes/CppQtCreatorProFile/qtcreatorprofilezipscript.h OTHER_FILES += \     ../../Classes/CppQtCreatorProFile/Licence.txt` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppQtCreatorProFile/qtcreatorprofile.h ----------------------------------------- - -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` //--------------------------------------------------------------------------- /* QtCreatorProFile, class to parse Qt Project files Copyright 2010-2015 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppQtCreatorProFile.htm //--------------------------------------------------------------------------- #ifndef QTCREATORPROFILE_H #define QTCREATORPROFILE_H #include #include #include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #include #include #include "about.h" #pragma GCC diagnostic pop namespace ribi { ///QtCreatorProFile parses .pro files struct QtCreatorProFile {   ///Parse a .pro file, throws a std::logic_error if   ///filename is not a regular file   explicit QtCreatorProFile(const std::string& filename);   QtCreatorProFile(const QtCreatorProFile&) = delete;   QtCreatorProFile& operator=(const QtCreatorProFile&) = delete;   ///Obtain this class its About information   static ribi::About GetAbout() noexcept;   ///Obtain the CONFIG   const std::set& GetConfig() const noexcept { return m_config; }   ///Obtain the DEFINES   const std::set& GetDefines() const noexcept { return m_defines; }   ///Obtain the FORMS   const std::set& GetForms() const noexcept { return m_forms; }   ///Obtain the HEADERS   const std::set& GetHeaders() const noexcept { return m_headers; }   ///Obtain the INCLUDEPATH   const std::set& GetIncludepath() const noexcept { return m_includepath; }   ///Obtain the LIBS   const std::set& GetLibs() const noexcept { return m_libs; }   ///Obtain the OTHER_FILES   const std::set& GetOtherFiles() const noexcept { return m_other_files; }   ///Obtain the include(something.pri)   const std::set& GetPriFiles() const noexcept { return m_pri_files; }   ///Get the project file its file name   const std::string& GetQtCreatorProFilename() const noexcept { return m_pro_filename; }   ///Obtain the QMAKE_CXXFLAGS   const std::set& GetQmakeCxxflags() const noexcept { return m_qmake_cxxflags; }   ///Obtain the QT   const std::set& GetQt() const noexcept { return m_qt; }   ///Obtain the RESOURCES   const std::set& GetResources() const noexcept { return m_resources; }   ///Obtain the SOURCES   const std::set& GetSources() const noexcept { return m_sources; }   ///Obtain the TARGET   const std::set& GetTarget() const noexcept { return m_target; }   ///Obtain the TEMPLATE   const std::set& GetTemplate() const noexcept { return m_template; }   ///Obtain this class its version   static std::string GetVersion() noexcept;   ///Obtain this class its version history   static std::vector GetVersionHistory() noexcept;   ///Set the CONFIG   void SetConfig(const std::set& s) { m_config = s; }   ///Set the DEFINES   void SetDefines(const std::set& s) { m_defines = s; }   ///Set the FORMS   void SetForms(const std::set& s) { m_forms = s; }   ///Set the HEADERS   void SetHeaders(const std::set& s) { m_headers = s; }   ///Set the INCLUDEPATH   void SetIncludepath(const std::set& s) { m_includepath = s; }   ///Set the LIBS   void SetLibs(const std::set& s) { m_libs = s; }   ///Set the OTHER_FILES   void SetOtherFiles(const std::set& s) { m_other_files = s; }   ///Set the include(something.pri) files   void SetPriFiles(const std::set& s) { m_pri_files = s; }   ///Set the project file its file name   void SetQtCreatorProFilename(const std::string& s) { m_pro_filename = s; }   ///Set the QMAKE_CXXFLAGS   void SetQmakeCxxflags(const std::set& s) { m_qmake_cxxflags = s; }   ///Set the QT   void SetQt(const std::set& s) { m_qt = s; }   ///Set the RESOURCES   void SetResources(const std::set& s) { m_resources = s; }   ///Set the SOURCES   void SetSources(const std::set& s)  { m_sources = s; }   ///Set the TARGET   void SetTarget(const std::set& s) { m_target = s; }   ///Set the TEMPLATE   void SetTemplate(const std::set& s) { m_template = s; }   private:   ///Be sure the class is correctly deleted   ~QtCreatorProFile() noexcept {}   friend void boost::checked_delete<>(QtCreatorProFile* x);   ///The items at CONFIG   std::set m_config;   ///The items at DEFINES   std::set m_defines;   ///The items at FORMS   std::set m_forms;   ///The items at HEADERS   std::set m_headers;   ///The items at INCLUDEPATH   std::set m_includepath;   ///The items at LIBS   std::set m_libs;   ///The items at OTHER_FILES   std::set m_other_files;   ///The include(something.pri) files   std::set m_pri_files;   ///The .pro file to parse   std::string m_pro_filename;   ///The items at QMAKE_CXXFLAGS   std::set m_qmake_cxxflags;   ///The items at QT   std::set m_qt;   ///The items at RESOURCES   std::set m_resources;   ///The item at TARGET   std::set m_target;   ///The items at TEMPLATE   std::set m_template;   ///The items at SOURCES   std::set m_sources;   void DoReplacements(std::vector& v);   ///Parse the .pro file its content, split into lines   void Parse(std::stringstream& data);   void RemoveComments(std::vector& v);   #ifndef NDEBUG   static void Test() noexcept;   #endif   friend std::ostream& operator<<(std::ostream& os, const QtCreatorProFile& p);   friend bool operator==(const QtCreatorProFile& lhs, const QtCreatorProFile& rhs); }; std::ostream& operator<<(std::ostream& os, const QtCreatorProFile& p); bool operator==(const QtCreatorProFile& lhs, const QtCreatorProFile& rhs); } //~namespace ribi #endif // QTCREATORPROFILE_H` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppQtCreatorProFile/qtcreatorprofile.cpp ------------------------------------------- - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` //--------------------------------------------------------------------------- /* QtCreatorProFile, class to parse Qt Project files Copyright 2010-2015 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppQtCreatorProFile.htm //--------------------------------------------------------------------------- #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include "qtcreatorprofile.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "fileio.h" #include "trace.h" #include "testtimer.h" #pragma GCC diagnostic pop ribi::QtCreatorProFile::QtCreatorProFile(const std::string& filename)   :     m_config{},     m_defines{},     m_forms{},     m_headers{},     m_includepath{},     m_libs{},     m_other_files{},     m_pri_files{},     m_pro_filename{fileio::FileIo().ConvertPathToUnix(filename)},     m_qmake_cxxflags{},     m_qt{},     m_resources{},     m_target{},     m_template{},     m_sources{} {   #ifndef NDEBUG   Test();   #endif   if (!ribi::fileio::FileIo().IsRegularFile(m_pro_filename))   {     std::stringstream s;     s << __FILE__ << "(" <<  (__LINE__) <<  ") : "       << "Filename '" << m_pro_filename << "' must be a regular file";     throw std::logic_error(s.str().c_str());   }   assert(fileio::FileIo().IsUnixPath(m_pro_filename));   if (!fileio::FileIo().IsUnixPath(m_pro_filename))   {     std::stringstream s;     s << __FILE__ << "(" <<  (__LINE__) <<  ") : "       << "Filename '" << m_pro_filename << "' must have a Linux-styl path "       << " (this is, folders must be seperated by a slash, instead of a backslash)"     ;     throw std::logic_error(s.str().c_str());   }   std::vector v{ribi::fileio::FileIo().FileToVector(m_pro_filename)};   RemoveComments(v);   DoReplacements(v);   std::stringstream data;   std::copy(std::begin(v),std::end(v),std::ostream_iterator(data," "));   Parse(data); } void ribi::QtCreatorProFile::DoReplacements(std::vector& v) {   for (std::string& s: v)   {     boost::algorithm::replace_all(s,"include (","include(");   } } ribi::About ribi::QtCreatorProFile::GetAbout() noexcept {   ribi::About a(     "Richel Bilderbeek",     "QtCreatorProFile",     "class to parse Qt Project files",     "the 19th of August 2013",     "2010-2015",     "http://www.richelbilderbeek.nl/CppQtCreatorProFile.htm",     GetVersion(),     GetVersionHistory());   return a; } std::string ribi::QtCreatorProFile::GetVersion() noexcept {   return "3.0"; } std::vector ribi::QtCreatorProFile::GetVersionHistory() noexcept {   return {     "2010-12-19: version 1.0: initial version",     "2011-01-06: version 1.1: added GetCommonRoot and GetLibs member functions, added operator<<",     "2011-09-11: version 1.2: fixed bug",     "2012-02-25: version 1.3: added GetAbout member function",     "2012-02-28: version 1.4: added support for INCLUDEPATH, FORMS, OTHER_FILES, RESOURCES and QMAKE_CXXFLAGS",     "2012-05-30: version 1.5: added SimplifyPath",     "2012-08-13: version 1.6: modifiers like win32 and unix are ignored, instead of yielding an error",     "2012-12-23: version 1.7: set destructor to private, except for boost::checked_delete",     "2012-12-23: version 1.8: renamed to QtCreatorProFile due to naming conflicts when cross-compiling",     "2013-05-18: version 2.0: simplified architecture by removing file I/O",     "2013-08-19: version 2.1: replaced Boost.Regex by Boost.Xpressive, removed Boost.Filesystem",     "2014-01-27: version 2.2: removes all comments, can detect includes of .pri files",     "2014-05-02: version 3.0: use UNIX path seperators only"   }; } void ribi::QtCreatorProFile::Parse(std::stringstream& data) {   const bool verbose{false};   std::set * p = nullptr; //A set to write to   enum class Prefix { none, plus, minus };   Prefix prefix = Prefix::none;   while (data)   {     std::string s;     data >> s;     if (verbose) { TRACE(s); }     assert(s[0] != '#' && "Comments are already removed");     if (s[0] == '{') continue;     if (s[0] == '}') continue;     if (s[0] == '\\') continue;     if (s.size() > 7 && s.substr(0,7) == "include")     {       std::string t = s.substr(8,s.size() - 8 - 1);       if (verbose) { TRACE(t); }       while (t[0] == ' ' || t[0] == '(') t = t.substr(1,t.size()-1);       if (verbose) { TRACE(t); }       while (t.back() == ' ' || t.back() == ')') t.pop_back();       if (verbose) { TRACE(t); }       assert(t.find('(') == std::string::npos);       assert(t.find(')') == std::string::npos);       m_pri_files.insert(t);       continue;     }     const std::vector conditional_sections {       "unix", "win32", "static", "debug", "release"     };     if (std::count(conditional_sections.begin(),conditional_sections.end(),s))     {       p = nullptr;       continue;     }     const std::map* > m {       { "CONFIG"        ,&m_config },       { "DEFINES"       ,&m_defines },       { "FORMS"         ,&m_forms },       { "HEADERS"       ,&m_headers },       { "INCLUDEPATH"   ,&m_includepath },       { "LIBS"          ,&m_libs },       { "OTHER_FILES"   ,&m_other_files },       { "QMAKE_CXXFLAGS",&m_qmake_cxxflags },       { "QT"            ,&m_qt },       { "RESOURCES"     ,&m_resources },       { "SOURCES"       ,&m_sources },       { "TARGET"        ,&m_target },       { "TEMPLATE"      ,&m_template }     };     const std::map* >::const_iterator iter {       std::find_if(std::begin(m),std::end(m),         [s](const std::pair* > sub_pair)         {           return sub_pair.first == s;         }       )     };     if (iter != std::end(m))     {       if (verbose) { const std::string msg = "Set pointer to " + iter->first; TRACE(msg); }       p = iter->second;       prefix = Prefix::none;       continue;     }     //Determine prefixes     bool has_prefixes = true;     while (has_prefixes)     {       has_prefixes = false;       if (!s.empty() && s[0] == '+')       {         prefix = Prefix::plus;         s = s.substr(1,s.size() - 1);         has_prefixes = true;       }       else if (!s.empty() && s[0] == '-')       {         prefix = Prefix::minus;         s = s.substr(1,s.size() - 1);         has_prefixes = true;       }       else if (!s.empty() && s[0] == '\\')       {         s = s.substr(1,s.size() - 1);         has_prefixes = true;       }       else if (!s.empty() && s[0] == '=')       {         s = s.substr(1,s.size() - 1);         has_prefixes = true;       }     }     //Remove possible postfix     if (!s.empty())     {       if (s[ s.size() - 1] == '\\') s.resize(s.size() - 1);     }     if (p && !s.empty())     {       if (verbose) { const std::string msg = "Added " + s; TRACE(msg); }       p->insert(         (prefix == Prefix::minus ? "-" : "") + s);     }   } } void ribi::QtCreatorProFile::RemoveComments(std::vector& v) {   for (std::string& s: v)   {     const std::string t = boost::algorithm::trim_copy(s);     if (t[0] == '#')     {       s = "";       continue;     }     if (t.size() >= 7 && t.substr(0,7) == "message")     {       s = "";       continue;     }     const auto iter = std::find(std::begin(t),std::end(t),'#');     if (iter != std::end(t))     {       s.assign(std::begin(t),iter);     }     assert(std::find(std::begin(s),std::end(s),'#') == std::end(s)       && "Every comment is removed");   } } #ifndef NDEBUG void ribi::QtCreatorProFile::Test() noexcept {   //Test exactly once   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   fileio::FileIo();   const TestTimer test_timer(__func__,__FILE__,1.0);   {     const std::string mypath { fileio::FileIo().GetTempFileName() };     {       std::ofstream f(mypath);       f << "SOURCES += qtmain.cpp";     }     //Check the project file     const QtCreatorProFile p(mypath);     assert(p.GetSources().size() == 1);     assert(p.GetSources().count("qtmain.cpp"));     fileio::FileIo().DeleteFile(mypath.c_str());   }   {     const std::string mypath { fileio::FileIo().GetTempFileName() };     {       std::ofstream f(mypath);       f << "include(something.pri)";     }     //Check the project file     const QtCreatorProFile p(mypath);     assert(p.GetPriFiles().size() == 1);     assert(p.GetPriFiles().count("something.pri"));     fileio::FileIo().DeleteFile(mypath.c_str());   }   {     const std::string mypath { fileio::FileIo().GetTempFileName() };     {       std::ofstream f(mypath);       f << "include (something.pri)";     }     //Check the project file     const QtCreatorProFile p(mypath);     assert(p.GetPriFiles().size() == 1);     assert(p.GetPriFiles().count("something.pri"));     fileio::FileIo().DeleteFile(mypath.c_str());   }   {     const std::string mypath { fileio::FileIo().GetTempFileName() };     {       std::ofstream f(mypath);       f << "HEADERS += header.h #Must remove this comment";     }     //Check the project file     const QtCreatorProFile p(mypath);     assert(p.GetHeaders().size() == 1);     assert(p.GetHeaders().count("header.h"));     fileio::FileIo().DeleteFile(mypath.c_str());   }   {     const std::string mypath { fileio::FileIo().GetTempFileName() };     {       std::ofstream f(mypath);       f << "#-------------------------------------------------\n"         << "#\n"         << "# Project created by QtCreator 2010-12-19T16:24:53\n"         << "#\n"         << "#-------------------------------------------------\n"         << "QT       += core\n"         << "QT       -= gui\n"         << "LIBS     += -lwt -lboost_regex\n"         << "TARGET = ToolTestQtCreatorProFile\n"         << "CONFIG   += console\n"         << "CONFIG   -= app_bundle\n"         << "TEMPLATE = app\n"         << "SOURCES += main.cpp \\\n"         << "    profile.cpp\n"         << "HEADERS += \\\n"         << "    profile.h";     }     //Check the project file     const QtCreatorProFile p(mypath);     assert(p.GetConfig().size() == 2);     assert(p.GetConfig().count("console"));     assert(p.GetConfig().count("-app_bundle"));     assert(p.GetHeaders().size() == 1);     assert(p.GetHeaders().count("profile.h"));     assert(p.GetLibs().size() == 2);     assert(p.GetLibs().count("-lwt"));     assert(p.GetLibs().count("-lboost_regex"));     assert(p.GetQtCreatorProFilename() == mypath);     assert(p.GetQt().size() == 2);     assert(p.GetQt().count("core"));     assert(p.GetQt().count("-gui"));     assert(p.GetSources().size() == 2);     assert(p.GetSources().count("main.cpp"));     assert(p.GetSources().count("profile.cpp"));     assert(p.GetTarget().count("ToolTestQtCreatorProFile") == 1);     assert(p.GetTemplate().size() == 1);     assert(p.GetTemplate().count("app"));     {       std::stringstream ss;       ss << p << '\n';     }     //TRACE("Test QtCreatorProFile::operator==");     {       QtCreatorProFile q(mypath);       assert(p == q);     }     fileio::FileIo().DeleteFile(mypath.c_str());   }   //TRACE("Test QtCreatorProFile::Merge");   {     const std::string mypath1 { fileio::FileIo().GetTempFileName() };     const std::string mypath2 { fileio::FileIo().GetTempFileName() };     {       std::ofstream f(mypath1);       f << "#-------------------------------------------------\n"         << "#\n"         << "# Project created by QtCreator 2010-12-19T16:24:53\n"         << "#\n"         << "#-------------------------------------------------\n"         << "QT       += core\n"         << "QT       -= gui\n"         << "LIBS     += -lwt -lboost_regex\n"         << "TARGET = ToolTestQtCreatorProFileWebsite\n"         << "CONFIG   += console\n"         << "CONFIG   -= app_bundle\n"         << "TEMPLATE = app\n"         << "SOURCES += wtmain.cpp \\\n"         << "    profile.cpp\n"         << "HEADERS += \\\n"         << "    profile.h";     }     {       std::ofstream f(mypath2);       f << "#-------------------------------------------------\n"         << "#\n"         << "# Project created by QtCreator 2010-12-19T16:24:53\n"         << "#\n"         << "#-------------------------------------------------\n"         << "QT       -= core\n"         << "QT       -= gui\n"         << "LIBS     += -lboost_regex\n"         << "TARGET = ToolTestQtCreatorProFileConsole\n"         << "CONFIG   += console\n"         << "CONFIG   -= app_bundle\n"         << "TEMPLATE = app\n"         << "SOURCES += main.cpp \\\n"         << "    profile.cpp\n"         << "HEADERS += \\\n"         << "    profile.h";     }     //Check the project file     const boost::shared_ptr p1(new QtCreatorProFile(mypath1));     const boost::shared_ptr p2(new QtCreatorProFile(mypath2));     fileio::FileIo().DeleteFile(mypath1.c_str());     fileio::FileIo().DeleteFile(mypath2.c_str());   }   //Test conditionals   {     //Create a project file     const std::string mypath { fileio::FileIo().GetTempFileName() };     {       std::ofstream f(mypath);       f         << "QT       += core\n"         << "unix {\n"         << "SOURCES += \\\n"         << "    unix_main.cpp \\\n"         << "}\n"         << "win32 {\n"         << "TARGET = TestTarget\n"         << "SOURCES += win_main.cpp\n"         << "}\n"         << "SOURCES += profile.cpp\n"         << "HEADERS += \\\n"         << "    profile.h";     }     //Check the project file     const QtCreatorProFile p(mypath);     assert(p.GetQt().size() == 1);     assert(p.GetQt().count("core"));     assert(p.GetSources().size() == 3);     assert(p.GetSources().count("unix_main.cpp"));     assert(p.GetSources().count("win_main.cpp"));     assert(p.GetSources().count("profile.cpp"));     assert(p.GetHeaders().size() == 1);     assert(p.GetHeaders().count("profile.h"));     //Test operator<<     {       std::stringstream ss;       ss << p << '\n';     }     //Test operator==     {       QtCreatorProFile q(mypath);       assert(p == q);     }     fileio::FileIo().DeleteFile(mypath.c_str());   } } #endif std::ostream& ribi::operator<<(std::ostream& os, const QtCreatorProFile& p) {   os << "\n";   for (const std::string pri: p.GetPriFiles())   {     os << "include(" << pri << ")" << '\n';   }   {     const std::vector<       std::pair<         std::string, boost::function& (const QtCreatorProFile&)>         >       > v = {         { "CONFIG", &QtCreatorProFile::GetConfig },         { "DEFINES", &QtCreatorProFile::GetDefines },         { "FORMS", &QtCreatorProFile::GetForms },         { "HEADERS", &QtCreatorProFile::GetHeaders },         { "INCLUDEPATH", &QtCreatorProFile::GetIncludepath },         { "LIBS", &QtCreatorProFile::GetLibs },         { "OTHER_FILES", &QtCreatorProFile::GetOtherFiles },         { "QMAKE_CXXFLAGS", &QtCreatorProFile::GetQmakeCxxflags },         { "QT", &QtCreatorProFile::GetQt},         { "RESOURCES", &QtCreatorProFile::GetResources },         { "SOURCES", &QtCreatorProFile::GetSources },         { "TARGET", &QtCreatorProFile::GetTarget },         { "TEMPLATE", &QtCreatorProFile::GetTemplate }       };     std::for_each(v.begin(),v.end(),       [&os,&p](const std::pair& (const QtCreatorProFile&)> >& pair)       {         const std::set& w = pair.second(p);         if (!w.empty())         {           os << pair.first << " += \\\n";           if (w.size() > 1)           {             std::transform(w.begin(),--w.end(),std::ostream_iterator(os," \\\n"),               [](const std::string& s) { return "    " + s; } );           }           os << "    " + (*(--w.end())) + '\n';           os << "\n";         }       }     );   }   os << "\n";   os << "#--------------------------------------------------------------------------\n";   os << "# This file was created by:\n";   os << "#\n";   {     const std::vector v = p.GetAbout().CreateAboutText();     std::transform(v.begin(),v.end(),std::ostream_iterator(os,"\n"),       [](const std::string& s) { return "# " + s; } );   }   os << "#\n";   os << "#\n";   os << "#\n";   {     const std::vector v = p.GetAbout().CreateLicenceText();     std::transform(v.begin(),v.end(),std::ostream_iterator(os,"\n"),       [](const std::string& s) { return "# " + s; } );   }   os << "#--------------------------------------------------------------------------";   return os; } bool ribi::operator==(const QtCreatorProFile& lhs, const QtCreatorProFile& rhs) {   return        lhs.m_config == rhs.m_config     && lhs.m_defines == rhs.m_defines     && lhs.m_forms == rhs.m_forms     && lhs.m_headers == rhs.m_headers     && lhs.m_includepath == rhs.m_includepath     && lhs.m_libs == rhs.m_libs     && lhs.m_other_files == rhs.m_other_files     && lhs.m_pro_filename == rhs.m_pro_filename     && lhs.m_qmake_cxxflags == rhs.m_qmake_cxxflags     && lhs.m_qt == rhs.m_qt     && lhs.m_resources == rhs.m_resources     && lhs.m_target == rhs.m_target     && lhs.m_template == rhs.m_template     && lhs.m_sources == rhs.m_sources; }` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppQtCreatorProFile/qtcreatorprofilezipscript.h -------------------------------------------------- - -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` //--------------------------------------------------------------------------- /* QtCreatorProFile, class to parse Qt Project files Copyright 2010-2015 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppQtCreatorProFile.htm //--------------------------------------------------------------------------- #ifndef QTCREATORPROFILEZIPSCRIPT #define QTCREATORPROFILEZIPSCRIPT #include #include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #include #include #include "qtcreatorprofile.h" #pragma GCC diagnostic pop namespace ribi { ///Create a shell script to zip a Qt Creator .pro file struct QtCreatorProFileZipScript {   QtCreatorProFileZipScript(     const boost::shared_ptr pro_file   );   QtCreatorProFileZipScript(const QtCreatorProFileZipScript&) = delete;   QtCreatorProFileZipScript& operator=(const QtCreatorProFileZipScript&) = delete;   ///Create a script to zip all .pro files (and all they refer to) in a folder   static std::string CreateScript(const std::string& source_folder);   ///Obtain this class its About information   static About GetAbout() noexcept;   ///Obtain all filenames   const std::set& GetFilenames() const { return m_filenames; }   ///Obtain the .pro file   //const boost::shared_ptr GetProFile() const { return m_pro_file; }   const std::string& GetProFileName() const { return m_pro_file_name; }   ///Obtain this class its version   static std::string GetVersion() noexcept;   ///Obtain this class its version history   static std::vector GetVersionHistory() noexcept;   static boost::shared_ptr Merge(     const std::vector >& v);   ///Set all filenames   void SetFilenames(const std::set& filenames) { m_filenames = filenames; }   private:   ///Used when merging   QtCreatorProFileZipScript(     const std::set& filenames,     const std::string& pro_file_name);   ///Be sure the class is correctly deleted   ~QtCreatorProFileZipScript() noexcept {}   friend void boost::checked_delete<>(QtCreatorProFileZipScript* x);   ///All the files used by the QtCreatorProFile   std::set m_filenames;   ///The original .pro file its filename   const std::string m_pro_file_name;   //const boost::shared_ptr m_pro_file;   ///Create a QtCreatorProFile from every filename   static std::vector > CreateProFiles(const std::vector& pro_files);   ///Extract a QtCreatorProFile its filenames   const std::set ExtractFilenames(     const boost::shared_ptr & pro_file) const;   ///Get all the .pro files in a folder   //From http://www.richelbilderbeek.nl/CppGetProFilesInFolder.htm   static std::vector GetProAndPriFilesInFolder(const std::string& folder);   #ifndef NDEBUG   static void Test() noexcept;   #endif   friend std::ostream& operator<<(std::ostream& os,const QtCreatorProFileZipScript& script) noexcept; }; std::ostream& operator<<(std::ostream& os,const QtCreatorProFileZipScript& script) noexcept; } //~namespace ribi #endif // QTCREATORPROFILEZIPSCRIPT` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppQtCreatorProFile/qtcreatorprofilezipscript.cpp ---------------------------------------------------- - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` //--------------------------------------------------------------------------- /* QtCreatorProFile, class to parse Qt Project files Copyright 2010-2015 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppQtCreatorProFile.htm //--------------------------------------------------------------------------- #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #pragma GCC diagnostic ignored "-Wunused-but-set-parameter" #include "qtcreatorprofilezipscript.h" #include #include #include #include #include #include #include #include #include "fileio.h" #include "qrcfile.h" #include "qtcreatorprofile.h" #include "testtimer.h" #include "trace.h" #pragma GCC diagnostic pop struct PathOrdering {   bool operator()(const std::string& lhs, const std::string& rhs)   {     //Shortest files first     if (lhs.size() < rhs.size()) return true;     //Order same-length files alphabetically     if (lhs.size() == rhs.size() && lhs < rhs) return true;     return false;   } }; ribi::QtCreatorProFileZipScript::QtCreatorProFileZipScript(   const boost::shared_ptr pro_file)   : m_filenames(ExtractFilenames(pro_file)),     m_pro_file_name(pro_file->GetQtCreatorProFilename()) {   #ifndef NDEBUG   ribi::QtCreatorProFileZipScript::Test();   assert(fileio::FileIo().IsUnixPath(m_pro_file_name));   assert(pro_file);   for (const auto& s: m_filenames)   {     assert(ribi::fileio::FileIo().IsRegularFile(s));   }   #endif } ribi::QtCreatorProFileZipScript::QtCreatorProFileZipScript(   const std::set& filenames,   const std::string& pro_file_name)   : m_filenames(filenames),     m_pro_file_name(pro_file_name) { } std::vector > ribi::QtCreatorProFileZipScript::CreateProFiles(   const std::vector& filenames) {   std::vector > pro_files;   for (const std::string& filename: filenames)   {     assert(ribi::fileio::FileIo().IsRegularFile(filename));     const boost::shared_ptr pro_file(new ribi::QtCreatorProFile(filename));     assert(pro_file);     pro_files.push_back(pro_file);   }   return pro_files; } std::string ribi::QtCreatorProFileZipScript::CreateScript(const std::string& source_folder) {   if (!fileio::FileIo().IsFolder(source_folder))   {     std::stringstream s;     s << "QtCreatorProFileZipScript::CreateScript: folder '" << source_folder << "' not found";     throw std::runtime_error(s.str().c_str());   }   if (source_folder.find('\\') != std::string::npos)   {     std::stringstream s;     s << "QtCreatorProFileZipScript::CreateScript: folder '" << source_folder << "' contains Windows"       << "path seperators. Use slash instead of backslash";     throw std::runtime_error(s.str().c_str());   }   if (source_folder.substr(0,6) != "../../")   {     std::stringstream s;     s << "QtCreatorProFileZipScript::CreateScript: folder '" << source_folder << "' does"       << "not start with '../../'. Change the folder's name accordingly";     throw std::runtime_error(s.str().c_str());   }   assert(fileio::FileIo().IsFolder(source_folder));   assert(source_folder.substr(0,6) == "../../");   assert(fileio::FileIo().IsUnixPath(source_folder));   //Also include .pri files in that folder   std::vector pro_filenames = GetProAndPriFilesInFolder(source_folder);   //Add the .pri files in the .pro files   {     std::vector w(pro_filenames);     for (const std::string pro_filename: pro_filenames)     {       assert(ribi::fileio::FileIo().IsUnixPath(pro_filename));       const std::string full_pro_filename         = source_folder.empty()         ? std::string()         : source_folder + '/' + pro_filename       ;       #ifndef NDEBUG       if (!ribi::fileio::FileIo().IsRegularFile(full_pro_filename))       {         TRACE("ERROR");         TRACE(full_pro_filename);       }       #endif       assert(ribi::fileio::FileIo().IsRegularFile(full_pro_filename));       assert(ribi::fileio::FileIo().IsUnixPath(full_pro_filename));       const boost::shared_ptr pro_file(         new QtCreatorProFile(full_pro_filename)       );       assert(pro_file);       //Copy its .pri files to be scanned       for (const std::string pri_file: pro_file->GetPriFiles())       {         assert(ribi::fileio::FileIo().IsUnixPath(pri_file));         w.push_back(pri_file);       }     }     std::swap(w,pro_filenames);   }   //Create the scripts by merging QtCreatorProFiles   std::vector> scripts;   for (const std::string& pro_filename: pro_filenames)   {     assert(ribi::fileio::FileIo().IsUnixPath(pro_filename));     const std::string full_pro_filename       = fileio::FileIo().SimplifyPath(         source_folder       + '/'       + pro_filename       )     ;     #ifndef NDEBUG     if (!ribi::fileio::FileIo().IsRegularFile(full_pro_filename))     {       TRACE("ERROR");       TRACE(full_pro_filename);       TRACE(source_folder);       TRACE(pro_filename);       TRACE("BREAK");     }     if (!ribi::fileio::FileIo().IsUnixPath(full_pro_filename))     {       TRACE("ERROR");       TRACE(full_pro_filename);       TRACE(source_folder);       TRACE(pro_filename);       TRACE("BREAK");     }     #endif     assert(ribi::fileio::FileIo().IsRegularFile(full_pro_filename));     assert(fileio::FileIo().IsUnixPath(full_pro_filename));     const boost::shared_ptr pro_file(       new QtCreatorProFile(full_pro_filename));     assert(pro_file);     const boost::shared_ptr script(       new QtCreatorProFileZipScript(pro_file));     assert(script);     scripts.push_back(script);   }   const boost::shared_ptr merged_script     = ribi::QtCreatorProFileZipScript::Merge(scripts);   if (!merged_script)   {     return "Folder does not contain any .pro files";   }   else   {     std::stringstream script;     script << *merged_script;     return script.str();   } } const std::set ribi::QtCreatorProFileZipScript::ExtractFilenames(   const boost::shared_ptr& pro_file) const {   assert(pro_file);   std::vector v;   std::copy(pro_file->GetForms().begin(),pro_file->GetForms().end(),std::back_inserter(v));   std::copy(pro_file->GetHeaders().begin(),pro_file->GetHeaders().end(),std::back_inserter(v));   std::copy(pro_file->GetOtherFiles().begin(),pro_file->GetOtherFiles().end(),std::back_inserter(v));   std::copy(pro_file->GetResources().begin(),pro_file->GetResources().end(),std::back_inserter(v));   std::copy(pro_file->GetSources().begin(),pro_file->GetSources().end(),std::back_inserter(v));   //Copy all resources   for (const std::string qrc_filename_raw: pro_file->GetResources())   {     assert(ribi::fileio::FileIo().IsUnixPath(qrc_filename_raw));     const std::string qrc_filename_full         = qrc_filename_raw.size() < 7 || qrc_filename_raw.substr(0,6) != "../../"         ? ribi::fileio::FileIo().GetPath(pro_file->GetQtCreatorProFilename())         //? boost::filesystem::path(pro_file->GetQtCreatorProFilename()).parent_path().string()             + "/" + qrc_filename_raw         : qrc_filename_raw;     assert(qrc_filename_full.size() > 6);     assert(qrc_filename_full.substr(0,6) == "../../");     assert(ribi::fileio::FileIo().IsUnixPath(qrc_filename_full));     if (!ribi::fileio::FileIo().IsRegularFile(qrc_filename_full))     {       const std::string s = "Warning: Resource file \'" + qrc_filename_full + "\' not found";       TRACE(s);       continue;     }     assert(ribi::fileio::FileIo().IsRegularFile(qrc_filename_full));     assert(qrc_filename_full.size() > 6 && qrc_filename_full.substr(0,6) == "../../");     assert(qrc_filename_full.size() > 7 && qrc_filename_full.substr(0,7) != "../../.");     const boost::shared_ptr qrc_file(       new QrcFile(qrc_filename_full));     assert(qrc_file);     //BUG: QrcFile supplies its files without a full path     //std::copy(qrc_file->GetFiles().begin(),qrc_file->GetFiles().end(),std::back_inserter(v));     for (const std::string& filename : qrc_file->GetFiles())     {       assert(ribi::fileio::FileIo().IsUnixPath(filename));       const std::string full_resource_item_name         = ribi::fileio::FileIo().GetPath(qrc_filename_full) + "/" + filename;       //  = boost::filesystem::path(qrc_filename_full).parent_path().string() + "/" + filename;       assert(ribi::fileio::FileIo().IsRegularFile(full_resource_item_name));       assert(ribi::fileio::FileIo().IsUnixPath(full_resource_item_name));       v.push_back(full_resource_item_name);     }   }   //Add paths if needed   std::vector filenames;   assert(pro_file);   assert(ribi::fileio::FileIo().IsRegularFile(pro_file->GetQtCreatorProFilename()));   filenames.push_back(pro_file->GetQtCreatorProFilename());   for (const std::string filename: v)   {     if (!filename.empty() && (filename[0] == '/' || filename[0] == '.'))     {       #ifndef NDEBUG       if (!ribi::fileio::FileIo().IsRegularFile(filename))       {         TRACE("ERROR");         TRACE(filename);         TRACE("BREAK");       }       #endif       assert(ribi::fileio::FileIo().IsRegularFile(filename));       assert(ribi::fileio::FileIo().IsUnixPath(filename));       filenames.push_back(filename);     }     else if (!filename.empty() && filename[0] != '/' && filename[0] != '.')     {       //Add full path       const std::string s         = ribi::fileio::FileIo().GetPath(pro_file->GetQtCreatorProFilename());       //  = boost::filesystem::path(pro_file->GetQtCreatorProFilename()).parent_path().string();       assert(s.size() > 6);       assert(ribi::fileio::FileIo().IsUnixPath(s));       const std::string t = s + "/" + filename;       //TRACE(t);       assert(ribi::fileio::FileIo().IsRegularFile(t));       assert(ribi::fileio::FileIo().IsUnixPath(t));       filenames.push_back(t);     }   }   #ifndef NDEBUG   for (const auto& s: filenames) { assert(ribi::fileio::FileIo().IsRegularFile(s)); }   #endif // NDEBUG   for (std::string& s: filenames) { s = fileio::FileIo().SimplifyPath(s); }   #ifndef NDEBUG   for (const auto& s: filenames) { assert(ribi::fileio::FileIo().IsRegularFile(s)); }   #endif // NDEBUG   std::sort(filenames.begin(),filenames.end());   filenames.erase( std::unique(filenames.begin(),filenames.end()), filenames.end() );   std::set s;   std::copy(filenames.begin(),filenames.end(),std::inserter(s,s.begin()));   return s; } ribi::About ribi::QtCreatorProFileZipScript::GetAbout() noexcept {   ribi::About a(     "Richel Bilderbeek",     "QtCreatorProFileZipScript",     "class to create a zip file from a .pro file",     "the 19th of May 2013",     "2013-2015",     "http://www.richelbilderbeek.nl/CppQtCreatorProFileZipScript.htm",     GetVersion(),     GetVersionHistory());   a.AddLibrary("QrcFile version: " + QrcFile::GetVersion());   a.AddLibrary("QtCreatorProFile version: " + QtCreatorProFile::GetVersion());   a.AddLibrary("Trace version: " + Trace::GetVersion());   return a; } //std::vector ribi::QtCreatorProFileZipScript::GetProFilesInFolder(const std::string& folder) //{ //  assert(fileio::FileIo().IsFolder(folder)); //  return ribi::fileio::FileIo().GetFilesInFolderByRegex(folder,".*\\.(pro)\\>"); //} std::vector ribi::QtCreatorProFileZipScript::GetProAndPriFilesInFolder(const std::string& folder) {   assert(fileio::FileIo().IsFolder(folder));   const std::vector v = ribi::fileio::FileIo().GetFilesInFolderByRegex(folder,".*\\.(pro|pri)\\>");   return v; } std::string ribi::QtCreatorProFileZipScript::GetVersion() noexcept {   return "2.0"; } std::vector ribi::QtCreatorProFileZipScript::GetVersionHistory() noexcept {   return {     "2013-05-19: version 1.0: initial version",     "2013-08-19: version 1.1: replaced Boost.Regex by Boost.Xpressive",     "2013-12-05: version 1.2: add support for .pri files"     "2014-04-25: version 1.3: fixed SimplifiedPath bug",     "2014-05-02: version 2.0: use UNIX path seperators only"   }; } boost::shared_ptr ribi::QtCreatorProFileZipScript::Merge(   const std::vector >& scripts) {   boost::shared_ptr p;   if (scripts.empty()) return p;   std::set all_filenames;   std::string pro_file_name;   for (const boost::shared_ptr& script: scripts)   {     const auto filenames = script->GetFilenames();     all_filenames.insert(filenames.begin(),filenames.end());     pro_file_name = script->GetProFileName(); //Just for having something   }   p.reset(new QtCreatorProFileZipScript(all_filenames,pro_file_name));   assert(p);   return p; } #ifndef NDEBUG void ribi::QtCreatorProFileZipScript::Test() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   ribi::fileio::FileIo();   const TestTimer test_timer(__func__,__FILE__,1.0);   //Test basic functions on this project with going two folders down   const std::vector pro_file_names     =     {       "../../Tools/ToolCreateQtProjectZipFile/ToolCreateQtProjectZipFileDesktop.pro",       "../../Tools/ToolCodeToHtml/ToolCodeToHtmlDesktop.pro",       "../../Tools/ToolKalmanFilterer/ToolKalmanFiltererDesktop.pro",       "../../ProjectRichelBilderbeek/ProjectRichelBilderbeek/ProjectRichelBilderbeekDesktop.pro"     };   for (const std::string& pro_file_name: pro_file_names)   {     if (!ribi::fileio::FileIo().IsRegularFile(pro_file_name)) continue;     assert(ribi::fileio::FileIo().IsRegularFile(pro_file_name));     const boost::shared_ptr pro_file(       new QtCreatorProFile(pro_file_name) );     assert(pro_file);     const boost::shared_ptr zip_script(       new QtCreatorProFileZipScript(pro_file) );     assert(zip_script);     const std::set filenames = zip_script->GetFilenames();     for (const std::string& filename: filenames)     {       if (!ribi::fileio::FileIo().IsRegularFile(filename))       {         const std::string warning = "Warning: file \'" + filename + "\' not found";         TRACE(warning);         continue;       }       assert(ribi::fileio::FileIo().IsRegularFile(filename));     }   }   //Test that GetProFilesInFolder detects an additional .pro file   //being added to a folder   {     const std::string tmp_pro_filename { fileio::FileIo().GetTempFileName(".pro") };     //Count the current number of .pro files     const std::size_t n = GetProAndPriFilesInFolder("").size();     //Add a .pro file     {       std::ofstream f(tmp_pro_filename.c_str());       f.close();       assert(ribi::fileio::FileIo().IsRegularFile(tmp_pro_filename));     }     //Count the current number of .pro and .pri files again     const std::size_t p = GetProAndPriFilesInFolder("").size();     #ifndef NDEBUG     if (n != p-1)     {       TRACE("ERROR: GetProFilesInFolder does not detect .pro files correctly");     }     #endif     assert(n == p - 1);     fileio::FileIo().DeleteFile(tmp_pro_filename);     const std::size_t q = GetProAndPriFilesInFolder("").size();     assert(n == q);   } } #endif std::ostream& ribi::operator<<(std::ostream& os,const QtCreatorProFileZipScript& script) noexcept {   #ifndef NDEBUG   {     const std::string s = script.GetProFileName();     assert(s.size() > 6);     assert(s.substr(0,6) == "../../");     assert(ribi::fileio::FileIo().IsUnixPath(s));   }   #endif   os << "#!/bin/sh" << '\n';   os << "# Created from file '"      << script.GetProFileName()      << "\'" << '\n';   os << '\n';   //if (!m_folder_name_for_sloccount.empty())   //{   //  os << '\n'   //     << "echo \"Creating a sloccount file\"" << '\n'   //     << "sloccount " << m_folder_name_for_sloccount << " > sloccount.txt" << '\n'   //     << '\n';   //}   //if (!m_doxygen_filename.empty())   //{   //  os << "echo \"Creating documentation\"" << '\n'   //     << "doxygen \"" << m_doxygen_filename << "\"" << '\n';   //}   //os << '\n';   //os << "echo \"Removing user information\"" << '\n';   //os << "rm *.user" << '\n';   //os << '\n';   //os << "echo \"Removing possible temp file\"" << '\n';   //os << "rm copy.txt" << '\n';   //os << "rm tmp.txt" << '\n';   //os << '\n';   os << "echo \"Creating of all folders\"" << '\n';   os << '\n';   os << "mkdir Projects" << '\n';   //file names with full path   const auto file_names_vector = script.GetFilenames();   const std::set file_names(     file_names_vector.begin(),file_names_vector.end()   );   std::set folder_names;   //Add the folders added by the .pro file   for (const std::string filename: file_names)   {     assert(ribi::fileio::FileIo().IsRegularFile(filename));     assert(ribi::fileio::FileIo().IsUnixPath(filename));     std::string s = ribi::fileio::FileIo().GetPath(filename);     //Foldernames like '../../Classes/CppQrcFile' must be ignored or not occur here.     if (!(s[ s.size() - 1] != '.' || s[ s.size() - 2] != '.')) continue;     while (!s.empty())     {       const std::size_t old_len = s.size();       const std::string t = fileio::FileIo().SimplifyPath(s);       folder_names.insert(t);       s = ribi::fileio::FileIo().GetPath(s);       assert(fileio::FileIo().IsUnixPath(s));       const std::size_t new_len = s.size();       if (new_len == old_len) { s = ""; }     }   }   for (const std::string& s: folder_names)   {     if (s.size() > 6 && s.substr(0,6) == "../../")     {       const std::string folder = s.substr(6,s.size() - 6);       assert(ribi::fileio::FileIo().IsUnixPath(folder));       if ( folder[ folder.size() - 1] == '.'         || folder[ folder.size() - 2] == '.'       )       {         TRACE("ERROR");         TRACE(folder);         TRACE("BREAK");       }       assert(folder[ folder.size() - 1] != '.');       assert(folder[ folder.size() - 2] != '.');       assert(folder[ folder.size() - 3] != '.');       assert(folder[ folder.size() - 4] != '.');       os << "mkdir Projects" << fileio::FileIo().GetPathSeperator() << folder << '\n';     }   }   os << '\n';   os << "echo \"Copying files\"" << '\n';   os << '\n';   for (const std::string& s: file_names)   {     assert(ribi::fileio::FileIo().IsUnixPath(s));     if (s.size() > 6 && s.substr(0,6) == "../../")     {       os << "cp " << s << " Projects/" << s.substr(6,s.size() - 6) << '\n';     }     else if (s.size() > 3 && s.substr(0,1) != ".")     {       //A file in the .pro file its folder       os << "cp " << s << " Projects/"         << ribi::fileio::FileIo().GetPath(script.GetProFileName())         << s << '\n'       ;     }   }   os << '\n';   os << "FILENAME=\""      << ribi::fileio::FileIo().GetPath( script.GetProFileName() )      //<< boost::filesystem::path( script.GetProFileName() ).parent_path().string()      << "Source\"" << '\n';   os << "ZIP_FILENAME=$FILENAME\".zip\"" << '\n';   os << '\n';   os << "echo \"Compressing files\"" << '\n';   os << '\n';   os << "zip -r $FILENAME Projects" << '\n';   os << '\n';   os << "echo \"Cleaning up\"" << '\n';   os << '\n';   os << "echo \"Emptying subfolders\"" << '\n';   os << '\n';   std::for_each(folder_names.rbegin(),folder_names.rend(),     [&os](const std::string& s)     {       if (s.size() > 6 && s.substr(0,6) == "../../")       {          os << "rm Projects/" + s.substr(6,s.size() - 6) << "/*.*" << '\n';       }     }   );   os << "rm Projects/*.*" << '\n';   std::for_each(folder_names.rbegin(),folder_names.rend(),     [&os](const std::string& s)     {       if (s.size() > 6 && s.substr(0,6) == "../../")       {         os << "rmdir Projects/" << s.substr(6,s.size()-6) << '\n';       }     }   );   os << "rmdir Projects" << '\n';   os << '\n';   os << "echo \"Done\"" << '\n';   os << '\n';   {     const std::vector w       = ribi::QtCreatorProFileZipScript::GetAbout().CreateAboutText();     std::transform(w.begin(),w.end(),     std::ostream_iterator(os,"\n"),       [](const std::string& s)       {         return "# " + s;       }     );   }   return os; }` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -  - +Moved to [the QtCreatorProFile class in the RibiClasses GitHub](https://github.com/richelbilderbeek/RibiClasses/tree/master/CppQtCreatorProFile). \ No newline at end of file diff --git a/content/CppQtQuadBezierArrowItem.md b/content/CppQtQuadBezierArrowItem.md index 8987de2f..28eb1cdb 100644 --- a/content/CppQtQuadBezierArrowItem.md +++ b/content/CppQtQuadBezierArrowItem.md @@ -1,142 +1,10 @@ - -  - -  - -  - -  - -  - -([C++](Cpp.md)) [QtQuadBezierArrowItem](CppQtQuadBezierArrowItem.md) -====================================================================== - -  - -![Qt](PicQt.png)![Qt -Creator](PicQtCreator.png)![Lubuntu](PicLubuntu.png) - -  +# ([C++](Cpp.md)) [QtQuadBezierArrowItem](CppQtQuadBezierArrowItem.md) [QtQuadBezierArrowItem](CppQtQuadBezierArrowItem.md) is a [QGraphicsItem](CppQGraphicsItem.md) for displaying a arrow that has a quadratic Bezier curve as its body. -  - For the math, see [QGraphicsPathItem example 5: Bezier quadratic lines with arrow heads](CppQGraphicsPathItemExample5.md). -Technical facts ---------------- - -  - -  - -  - -  - -  - -  - -./CppQtQuadBezierArrowItem/CppQtQuadBezierArrowItem.pri -------------------------------------------------------- - -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ` INCLUDEPATH += \     ../../Classes/CppQtQuadBezierArrowItem SOURCES += \     ../../Classes/CppQtQuadBezierArrowItem/qtquadbezierarrowitem.cpp \     ../../Classes/CppQtQuadBezierArrowItem/qtquadbezierarrowdialog.cpp HEADERS  += \     ../../Classes/CppQtQuadBezierArrowItem/qtquadbezierarrowitem.h \     ../../Classes/CppQtQuadBezierArrowItem/qtquadbezierarrowdialog.h OTHER_FILES += \     ../../Classes/CppQtQuadBezierArrowItem/Licence.txt FORMS += \     ../../Classes/CppQtQuadBezierArrowItem/qtquadbezierarrowdialog.ui` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - -  - -  - -  - -  - -  - -./CppQtQuadBezierArrowItem/qtquadbezierarrowdialog.h ----------------------------------------------------- - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef QTQUADBEZIERARROWDIALOG_H #define QTQUADBEZIERARROWDIALOG_H #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #pragma GCC diagnostic ignored "-Wunused-but-set-parameter" #include #include "qthideandshowdialog.h" #pragma GCC diagnostic pop namespace Ui {   class QtQuadBezierArrowDialog; } namespace ribi { struct QtQuadBezierArrowItem; ///Dialog to display the members of a QtQuadBezierArrowItem class QtQuadBezierArrowDialog final : public QtHideAndShowDialog {   Q_OBJECT public:   typedef boost::shared_ptr Arrow;   explicit QtQuadBezierArrowDialog(QWidget *parent = 0);   QtQuadBezierArrowDialog(const QtQuadBezierArrowDialog&) = delete;   QtQuadBezierArrowDialog& operator=(const QtQuadBezierArrowDialog&) = delete;   ~QtQuadBezierArrowDialog() noexcept;   Arrow GetArrow() const noexcept { return m_arrow; }   double GetUiMidX() const noexcept;   double GetUiMidY() const noexcept;   static std::string GetVersion() noexcept;   static std::vector GetVersionHistory() noexcept;   ///Set the arrow to work on   void SetArrow(const Arrow& arrow) noexcept;   void SetUiMidX(const double x) noexcept;   void SetUiMidY(const double y) noexcept; private slots:   void keyPressEvent(QKeyEvent * event) noexcept override final;   void on_box_focus_pen_width_valueChanged(double arg1);   void on_box_from_x_valueChanged(double arg1);   void on_box_from_y_valueChanged(double arg1);   void on_box_has_head_clicked();   void on_box_has_tail_clicked();   void on_box_mid_x_valueChanged(double arg1);   void on_box_mid_y_valueChanged(double arg1);   void on_box_normal_pen_width_valueChanged(double arg1);   void on_box_to_x_valueChanged(double arg1);   void on_box_to_y_valueChanged(double arg1); private:   Ui::QtQuadBezierArrowDialog *ui;   ///The arrow to work on   Arrow m_arrow;   void OnItemUpdated(const QtQuadBezierArrowItem * const item) noexcept;   #ifndef NDEBUG   static void Test() noexcept;   #endif }; } //~namespace ribi #endif // QTQUADBEZIERARROWDIALOG_H` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppQtQuadBezierArrowItem/qtquadbezierarrowdialog.cpp ------------------------------------------------------- - -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #pragma GCC diagnostic ignored "-Wunused-but-set-parameter" #include "qtquadbezierarrowdialog.h" #include #include #include #include #include #include "qtquadbezierarrowitem.h" #include "trace.h" #include "testtimer.h" #include "ui_qtquadbezierarrowdialog.h" #pragma GCC diagnostic pop ribi::QtQuadBezierArrowDialog::QtQuadBezierArrowDialog(QWidget *parent)   : QtHideAndShowDialog(parent),     ui(new Ui::QtQuadBezierArrowDialog),     m_arrow{} {   #ifndef NDEBUG   Test();   #endif   ui->setupUi(this); } ribi::QtQuadBezierArrowDialog::~QtQuadBezierArrowDialog() noexcept {   delete ui; } double ribi::QtQuadBezierArrowDialog::GetUiMidX() const noexcept {   return ui->box_mid_x->value(); } double ribi::QtQuadBezierArrowDialog::GetUiMidY() const noexcept {   return ui->box_mid_y->value(); } std::string ribi::QtQuadBezierArrowDialog::GetVersion() noexcept {   return "1.0"; } std::vector ribi::QtQuadBezierArrowDialog::GetVersionHistory() noexcept {   return {     "2014-07-29: version 1.0: initial version"   }; } void ribi::QtQuadBezierArrowDialog::on_box_from_x_valueChanged(double arg1) {   this->m_arrow->SetFromX(arg1); } void ribi::QtQuadBezierArrowDialog::on_box_from_y_valueChanged(double arg1) {   this->m_arrow->SetFromY(arg1); } void ribi::QtQuadBezierArrowDialog::on_box_has_head_clicked() {   m_arrow->SetHasHead(ui->box_has_head->isChecked()); } void ribi::QtQuadBezierArrowDialog::on_box_has_tail_clicked() {   m_arrow->SetHasTail(ui->box_has_tail->isChecked()); } void ribi::QtQuadBezierArrowDialog::on_box_mid_x_valueChanged(double arg1) {   this->m_arrow->SetMidX(arg1); } void ribi::QtQuadBezierArrowDialog::on_box_mid_y_valueChanged(double arg1) {   this->m_arrow->SetMidY(arg1); } void ribi::QtQuadBezierArrowDialog::on_box_normal_pen_width_valueChanged(double arg1) {   QPen new_pen = m_arrow->GetPen();   new_pen.setWidthF(arg1);   m_arrow->SetPen(new_pen); } void ribi::QtQuadBezierArrowDialog::on_box_focus_pen_width_valueChanged(double arg1) {   QPen new_pen = m_arrow->GetFocusPen();   new_pen.setWidthF(arg1);   m_arrow->SetFocusPen(new_pen); } void ribi::QtQuadBezierArrowDialog::on_box_to_x_valueChanged(double arg1) {   this->m_arrow->SetToX(arg1); } void ribi::QtQuadBezierArrowDialog::on_box_to_y_valueChanged(double arg1) {   this->m_arrow->SetToY(arg1); } void ribi::QtQuadBezierArrowDialog::OnItemUpdated(const QtQuadBezierArrowItem * const item) noexcept {   ui->box_focus_pen_width->setValue(item->GetFocusPen().widthF());   ui->box_from_x->setValue(item->GetFromItem()->x());   ui->box_from_y->setValue(item->GetFromItem()->y());   ui->box_has_head->setChecked(item->HasHead());   ui->box_has_tail->setChecked(item->HasTail());   ui->box_mid_x->setValue(item->GetMidItem()->x());   ui->box_mid_y->setValue(item->GetMidItem()->y());   ui->box_normal_pen_width->setValue(item->GetPen().widthF());   ui->box_to_x->setValue(item->GetToItem()->x());   ui->box_to_y->setValue(item->GetToItem()->y()); } void ribi::QtQuadBezierArrowDialog::keyPressEvent(QKeyEvent * event) noexcept {   if (event->key() == Qt::Key_Escape) { close(); return; } } void ribi::QtQuadBezierArrowDialog::SetArrow(const Arrow& arrow) noexcept {   const bool verbose{false};   assert(arrow);   if (m_arrow == arrow)   {     return;   }   if (verbose)   {     std::stringstream s;     s << "Setting arrow '" << (*arrow) << "'\n";   }   const auto focus_pen_after = arrow->GetFocusPen();   const auto from_item_after = arrow->GetFromItem();   const auto has_head_after = arrow->HasHead();   const auto mid_item_after = arrow->GetMidItem();   const auto pen_after = arrow->GetPen();   const auto has_tail_after = arrow->HasTail();   const auto to_item_after = arrow->GetToItem();   bool focus_pen_changed{true};   bool from_item_changed{true};   bool has_head_changed{true};   bool mid_item_changed{true};   bool pen_changed{true};   bool has_tail_changed{true};   bool to_item_changed{true};   if (m_arrow)   {     const auto focus_pen_before = m_arrow->GetFocusPen();     const auto from_item_before = m_arrow->GetFromItem();     const auto has_head_before = m_arrow->HasHead();     const auto mid_item_before = m_arrow->GetMidItem();     const auto pen_before = m_arrow->GetPen();     const auto has_tail_before = m_arrow->HasTail();     const auto to_item_before = m_arrow->GetToItem();     focus_pen_changed = focus_pen_before != focus_pen_after;     from_item_changed = from_item_before != from_item_after;     has_head_changed = has_head_before != has_head_after;     mid_item_changed = mid_item_before != mid_item_after;     pen_changed = pen_before != pen_after;     has_tail_changed = has_tail_before != has_tail_after;     to_item_changed = to_item_before != to_item_after;     if (verbose)     {       if (focus_pen_changed)       {         std::stringstream s;         s           << "Focus pen will change from width "           << focus_pen_before.widthF()           << " to "           << focus_pen_after.widthF()           << '\n'         ;         TRACE(s.str());       }       if (from_item_changed)       {         std::stringstream s;         s << "From item will change from " << from_item_before           << " to " << from_item_after << '\n';         TRACE(s.str());       }       if (has_head_changed)       {         std::stringstream s;         s << "Has head will change from '" << has_head_before           << "' to '" << has_head_after << "'\n";         TRACE(s.str());       }       if (mid_item_changed)       {         std::stringstream s;         s << "Mid item will change from " << mid_item_before           << " to " << mid_item_after << '\n';         TRACE(s.str());       }       if (pen_changed)       {         std::stringstream s;         s << "Normal pen will change from " << pen_before.widthF()           << " to " << pen_after.widthF() << '\n'         ;         TRACE(s.str());       }     }     //Disconnect m_arrow     m_arrow->m_signal_item_updated.disconnect(       boost::bind(&ribi::QtQuadBezierArrowDialog::OnItemUpdated,this,boost::lambda::_1)     );     /*     Not sure if I need this high detailed granulity     m_arrow->m_signal_base_changed.disconnect(       boost::bind(&ribi::QtQuadBezierArrowDialog::OnBaseChanged,this,boost::lambda::_1)     );     m_arrow->m_signal_font_changed.disconnect(       boost::bind(&ribi::QtQuadBezierArrowDialog::OnFontChanged,this,boost::lambda::_1)     );     m_arrow->m_signal_padding_changed.disconnect(       boost::bind(&ribi::QtQuadBezierArrowDialog::OnPaddingChanged,this,boost::lambda::_1)     );     m_arrow->m_signal_text_changed.disconnect(       boost::bind(&ribi::QtQuadBezierArrowDialog::OnTextChanged,this,boost::lambda::_1)     );     m_arrow->m_signal_text_pen_changed.disconnect(       boost::bind(&ribi::QtQuadBezierArrowDialog::OnTextPenChanged,this,boost::lambda::_1)     );   */   }   //Replace m_arrow by the new one   m_arrow = arrow;   assert(m_arrow->GetFocusPen() == focus_pen_after);   assert(m_arrow->GetFromItem() == from_item_after);   assert(m_arrow->GetMidItem() == mid_item_after);   assert(m_arrow->GetPen() == pen_after);   assert(m_arrow->GetToItem() == to_item_after);   assert(m_arrow->HasHead() == has_head_after);   assert(m_arrow->HasTail() == has_tail_after);   m_arrow->m_signal_item_updated.connect(     boost::bind(&ribi::QtQuadBezierArrowDialog::OnItemUpdated,this,boost::lambda::_1)   );   /* Not sure if I need this high detailed granulity   m_arrow->m_signal_base_changed.connect(     boost::bind(&ribi::QtQuadBezierArrowDialog::OnBaseChanged,this,boost::lambda::_1)   );   m_arrow->m_signal_font_changed.connect(     boost::bind(&ribi::QtQuadBezierArrowDialog::OnFontChanged,this,boost::lambda::_1)   );   m_arrow->m_signal_padding_changed.connect(     boost::bind(&ribi::QtQuadBezierArrowDialog::OnPaddingChanged,this,boost::lambda::_1)   );   m_arrow->m_signal_text_changed.connect(     boost::bind(&ribi::QtQuadBezierArrowDialog::OnTextChanged,this,boost::lambda::_1)   );   m_arrow->m_signal_text_pen_changed.connect(     boost::bind(&ribi::QtQuadBezierArrowDialog::OnTextPenChanged,this,boost::lambda::_1)   );   */   //Emit everything that has changed   if (      focus_pen_changed   || from_item_changed   || has_head_changed   || mid_item_changed   || pen_changed   || has_tail_changed   || to_item_changed   )   {      m_arrow->m_signal_item_updated(m_arrow.get());   }   /* Not sure if I need this high detailed granulity   if (focus_pen_changed)   {     m_arrow->m_signal_base_changed(m_arrow.get());   }   if (from_item_changed)   {     m_arrow->m_signal_font_changed(m_arrow.get());   }   if (has_head_changed)   {     m_arrow->m_signal_padding_changed(m_arrow.get());   }   if (mid_item_changed)   {     m_arrow->m_signal_text_changed(m_arrow.get());   }   if (pen_changed)   {     m_arrow->m_signal_text_pen_changed(m_arrow.get());   }   */   assert( arrow ==  m_arrow);   assert(*arrow == *m_arrow); } void ribi::QtQuadBezierArrowDialog::SetUiMidX(const double x) noexcept {   ui->box_mid_x->setValue(x); } void ribi::QtQuadBezierArrowDialog::SetUiMidY(const double y) noexcept {   ui->box_mid_y->setValue(y); } #ifndef NDEBUG void ribi::QtQuadBezierArrowDialog::Test() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     const boost::shared_ptr from{new QGraphicsSimpleTextItem};     const bool tail{false};     const boost::shared_ptr mid{new QGraphicsSimpleTextItem};     const bool head{true};     const boost::shared_ptr to{new QGraphicsSimpleTextItem};     const boost::shared_ptr arrow{       new QtQuadBezierArrowItem(from.get(),tail,mid.get(),head,to.get())     };     assert(arrow);   }   const TestTimer test_timer(__func__,__FILE__,1.0);   const bool verbose{false};   const boost::shared_ptr from{new QGraphicsSimpleTextItem};   const bool tail{false};   const boost::shared_ptr mid{new QGraphicsSimpleTextItem};   const bool head{true};   const boost::shared_ptr to{new QGraphicsSimpleTextItem};   const boost::shared_ptr arrow{     new QtQuadBezierArrowItem(from.get(),tail,mid.get(),head,to.get())   };   QtQuadBezierArrowDialog d;   d.SetArrow(arrow);   if (verbose) { TRACE("Get/SetUiMidX must be symmetric"); }   {     const double old_x{d.GetUiMidX()};     const double new_x{old_x + 10.0};     d.SetUiMidX(new_x);     assert(std::abs(d.GetUiMidX() - new_x) < 2.0);   }   if (verbose) { TRACE("Get/SetUiMidY must be symmetric"); }   {     const double old_y{d.GetUiMidY()};     const double new_y{old_y + 10.0};     d.SetUiMidY(new_y);     assert(std::abs(d.GetUiMidY() - new_y) < 2.0);   }   /*   assert(std::abs(ui->box_focus_pen_width->value() - m_arrow->GetFocusPen().widthF()) < 2.0);   assert(std::abs(ui->box_from_x->value() - m_arrow->GetFromItem()->x()) < 2.0);   assert(std::abs(ui->box_from_y->value() - m_arrow->GetFromItem()->y()) < 2.0);   assert(ui->box_has_head->isChecked() == m_arrow->HasHead());   assert(ui->box_has_tail->isChecked() == m_arrow->HasTail());   assert(std::abs(ui->box_mid_x->value() - m_arrow->GetMidItem()->x()) < 2.0);   assert(std::abs(ui->box_mid_y->value() - m_arrow->GetMidItem()->y()) < 2.0);   assert(std::abs(ui->box_normal_pen_width->value() - m_arrow->GetPen().widthF()) < 2.0);   assert(std::abs(ui->box_to_x->value() - m_arrow->GetToItem()->x()) < 2.0);   assert(std::abs(ui->box_to_y->value() - m_arrow->GetToItem()->y()) < 2.0);   */ } #endif` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppQtQuadBezierArrowItem/qtquadbezierarrowitem.h --------------------------------------------------- - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` //--------------------------------------------------------------------------- /* QtQuadBezierArrowItem, an quadratic Bezier arrow QGraphicsItem Copyright 2012-2015 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppQtQuadBezierArrowItem.htm //--------------------------------------------------------------------------- #ifndef QTQUADBEZIERARROWITEM_H #define QTQUADBEZIERARROWITEM_H #include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include #include #include #include #pragma GCC diagnostic pop namespace ribi { ///The QtQuadBezierArrowItem is a QGraphicsItem that ///follows the three QGraphicsItem positions ///If mid is nullptr, the line will be straight ///The QGraphicsItems supplied will not be deleted by QtQuadBezierArrowItem struct QtQuadBezierArrowItem : public QGraphicsItem {   QtQuadBezierArrowItem(     QGraphicsItem* const from,     const bool tail,     QGraphicsItem* const mid,     const bool head,     QGraphicsItem* const to,     QGraphicsItem* parent = 0   ) noexcept;   virtual ~QtQuadBezierArrowItem() noexcept {}   ///The rectangle that containg the item, used for rough calculations like   ///collision detection   QRectF boundingRect() const override final;   ///Get the QPen used to indicate that the arrow has focus   const QPen& GetFocusPen() const noexcept { return m_focus_pen; }   ///Get the item where the arrow originates from   ///(would the arrow and tail heads not be reversible)   ///Use the specific GetFrom* member functions to modify this item   const QGraphicsItem* GetFromItem() const noexcept { return m_from; }   double GetFromX() const noexcept { return m_from->x(); }   double GetFromY() const noexcept { return m_from->y(); }   ///Obtain the head point of the arrow, on the edge of the rectangle m_from   QPointF GetHead() const noexcept;   ///Get the item where the arrow pass through in the middle   ///Use the specific GetMid* member functions to modify this item   const QGraphicsItem* GetMidItem() const noexcept { return m_mid; }   double GetMidX() const noexcept { return m_mid->x(); }   double GetMidY() const noexcept { return m_mid->y(); }   ///Get the QPen used to draw a regular, non-focused, arrow   const QPen& GetPen() const noexcept { return m_pen; }   ///Obtain the tail point of the arrow, on the edge of the rectangle m_from   QPointF GetTail() const noexcept;   ///Get the item where the arrow points to   ///(would the arrow and tail heads not be reversible)   ///Use the specific GetTo* member functions to modify this item   const QGraphicsItem* GetToItem() const noexcept { return m_to; }   double GetToX() const noexcept { return m_to->x(); }   double GetToY() const noexcept { return m_to->y(); }   ///Obtain the version of this class   static std::string GetVersion() noexcept;   ///Obtain the version history of this class   static std::vector GetVersionHistory() noexcept;   ///Is there an arrow at the 'to' point (x2,y2)?   bool HasHead() const noexcept { return m_head; }   ///Is there an arrow at the 'from' point (x1,y1)?   bool HasTail() const noexcept { return m_tail; }   ///Respond to key press   void keyPressEvent(QKeyEvent *event) noexcept override final;   ///Respond to mouse press   void mousePressEvent(QGraphicsSceneMouseEvent *event) noexcept override final;   ///Paint a QtQuadBezierArrowItem   void paint(QPainter* painter, const QStyleOptionGraphicsItem *, QWidget *) noexcept override final;   ///Set if the arrow has a point at the head   void SetHasHead(const bool has_head) noexcept;   ///Set if the arrow has a point at the tail   void SetHasTail(const bool has_tail) noexcept;   ///Set the pen used to show focus   void SetFocusPen(const QPen& pen) noexcept;   ///Set the position of the from item   void SetFromPos(const QPointF& pos) noexcept;   void SetFromPos(const double x, const double y) noexcept { SetFromPos(QPointF(x,y)); }   void SetFromX(const double& x) noexcept { SetFromPos(x,GetFromY()); }   void SetFromY(const double& y) noexcept { SetFromPos(GetFromX(),y); }   ///Set the position of the middle item   void SetMidPos(const QPointF& pos) noexcept;   void SetMidPos(const double x, const double y) noexcept { SetMidPos(QPointF(x,y)); }   void SetMidX(const double& x) noexcept { SetMidPos(x,GetMidY()); }   void SetMidY(const double& y) noexcept { SetMidPos(GetMidX(),y); }   ///Set the regular pen used to draw the arrow   void SetPen(const QPen& pen) noexcept;   void SetShowBoundingRect(const bool show_bounding_rect) noexcept;   ///Set the position of the from item   void SetToPos(const QPointF& pos) noexcept;   void SetToPos(const double x, const double y) noexcept { SetToPos(QPointF(x,y)); }   void SetToX(const double& x) noexcept { SetToPos(x,GetToY()); }   void SetToY(const double& y) noexcept { SetToPos(GetToX(),y); }   ///More precise shape compared to boundingRect   ///In this example, it is redefined to ease selecting those thin lines   QPainterPath shape() const noexcept override final;   ///Emitted when the item has called   boost::signals2::signal m_signal_item_updated;   protected:   ///Change the cursor when the user moves the mouse cursor in the bounding rectangle   ///   void hoverEnterEvent(QGraphicsSceneHoverEvent *event) noexcept override final;   void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) noexcept override final;   void hoverMoveEvent(QGraphicsSceneHoverEvent *event) noexcept override final;   private:   ///The extra width given to the line for easier clicking   static const double m_click_easy_width;   ///The arrow used for indicating focus   QPen m_focus_pen;   ///The item where the arrow originates from   QGraphicsItem* const m_from;   ///Show arrow at head   bool m_head;   ///The item where the arrow pass through in the middle   QGraphicsItem* const m_mid;   ///The regular pen   QPen m_pen;   ///Show the bounding rectangle, used in debugging   bool m_show_bounding_rect;   ///Show arrow at tail   bool m_tail;   ///The item where the arrow points to   ///(would the arrow and tail heads not be reversible)   QGraphicsItem* const m_to;   ///Obtain point 'beyond'   QPointF GetBeyond() const noexcept;   ///Obtain point 'center'   /*   F    \     \   C  M  B     /    /   T   F = From   T = To   M = Mid   C = Center   B = Beyond   */   QPointF GetCenter() const noexcept;   QPointF pos() const = delete;   void setPos(const QPointF&) = delete;   void setX(const double&) = delete;   void setY(const double&) = delete;   #ifndef NDEBUG   static void Test() noexcept;   #endif   friend std::ostream& operator<<(std::ostream& os, const QtQuadBezierArrowItem& arrow) noexcept; }; std::ostream& operator<<(std::ostream& os, const QtQuadBezierArrowItem& arrow) noexcept; bool operator==(const QtQuadBezierArrowItem& lhs, const QtQuadBezierArrowItem& rhs) noexcept; } //~namespace ribi #endif // QTQUADBEZIERARROWITEM_H` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppQtQuadBezierArrowItem/qtquadbezierarrowitem.cpp ----------------------------------------------------- - -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` //--------------------------------------------------------------------------- /* QtQuadBezierArrowItem, an quadratic Bezier arrow QGraphicsItem Copyright 2012-2015 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppQtQuadBezierArrowItem.htm //--------------------------------------------------------------------------- #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #pragma GCC diagnostic ignored "-Wunused-but-set-parameter" #include "qtquadbezierarrowitem.h" #include #include #include #include #include #include #include #include #include #include #include #include "geometry.h" #include "testtimer.h" #include "trace.h" #pragma GCC diagnostic pop template bool operator==(   const boost::geometry::model::d2::point_xy& a,   const boost::geometry::model::d2::point_xy& b) {   return boost::geometry::equals(a,b);   //return a.x() == b.x() && a.y() == b.y(); } template bool operator!=(   const boost::geometry::model::d2::point_xy& a,   const boost::geometry::model::d2::point_xy& b) {   return !(a == b); } template bool operator==(   const boost::geometry::model::linestring > a,   const boost::geometry::model::linestring > b) {   return boost::geometry::equals(a,b);   //return (a[0] == b[0] && a[1] == b[1])   //  ||   (a[0] == b[1] && a[1] == b[0]); } template bool operator!=(   const boost::geometry::model::linestring > a,   const boost::geometry::model::linestring > b) {   return !(a==b); } ///Obtain the zero or one intersections between two finite lines //From http://www.richelbilderbeek.nl/CppGetLineLineIntersections.htm template const std::vector<   boost::geometry::model::d2::point_xy > GetLineLineIntersections(   const boost::geometry::model::linestring<     boost::geometry::model::d2::point_xy   > line1,   const boost::geometry::model::linestring<     boost::geometry::model::d2::point_xy   > line2) {   typedef boost::geometry::model::d2::point_xy Point;   std::vector points;   boost::geometry::intersection(line1,line2,points);   assert((points.empty() || points.size() == 1 || points.size() == 2)          && "0: The lines are parallel and not on top of each other"          && "1: The lines are crossing"          && "2: The lines are on top of each other"); //edit claudio_04122014   return points; } //Helper function to create a const line without a temporary std::vector template const boost::geometry::model::linestring > CreateLine(const std::vector >& v) {   return boost::geometry::model::linestring<     boost::geometry::model::d2::point_xy   >(std::begin(v),std::end(v)); } ///Obtain the zero, one or two intersections between a line and a rectanle //From http://www.richelbilderbeek.nl/CppGetLineRectIntersections.htm template const std::vector<   boost::geometry::model::d2::point_xy > GetLineRectIntersections(   const boost::geometry::model::linestring<     boost::geometry::model::d2::point_xy   > line,   const boost::geometry::model::box<     boost::geometry::model::d2::point_xy   > rect) {   typedef boost::geometry::model::d2::point_xy Point;   typedef boost::geometry::model::linestring Line;   //typedef boost::geometry::model::box Rect;   const Point p0 = Point(rect.min_corner().x(), rect.min_corner().y());   const Point p1 = Point(rect.max_corner().x(), rect.min_corner().y());   const Point p2 = Point(rect.min_corner().x(), rect.max_corner().y());   const Point p3 = Point(rect.max_corner().x(), rect.max_corner().y());   assert(p0 != p1); assert(p0 != p2); assert(p0 != p3);   assert(p1 != p0); assert(p1 != p2); assert(p1 != p3);   assert(p2 != p0); assert(p2 != p1); assert(p2 != p3);   assert(p3 != p0); assert(p3 != p1); assert(p3 != p2);   const std::vector rect_sides     =     {       CreateLine(std::vector( {p0,p1} )),       CreateLine(std::vector( {p0,p2} )),       CreateLine(std::vector( {p1,p3} )),       CreateLine(std::vector( {p2,p3} ))     };   std::vector points;   for (const auto side: rect_sides)   {     const std::vector v = GetLineLineIntersections(line,side);     std::copy(v.begin(),v.end(),std::back_inserter(points));   }   //claudio edit_05122014   //the vector points must be sorted before deleting the duplicates   //because std::unique works on consecutive elements   std::sort( points.begin(),points.end(),     [](const Point& lhs, const Point& rhs)     {       return lhs.x() == rhs.x() && lhs.y() == rhs.y();     }   );   //Remove doublures   //Put 'typename' before 'std::vector::iteratortype' to prevent getting the error below:   //error: need 'typename' before 'std::vector >::iterator'   //  because 'std::vector >' is a dependent scope   typename std::vector::iterator new_end = std::unique( points.begin(),points.end(),     [](const Point& lhs, const Point& rhs)     {       return lhs.x() == rhs.x() && lhs.y() == rhs.y();     }   );   points.erase(new_end,points.end());   assert(points.size() <= 2          && "0: The line does not cross the rectangle"          && "1: The line crosses one edge or one corner of the rectangle"          && "2: The line is on top of one edge or crosses two edges of the rectangle"          ); // edit claudio_04122014   return points; } const double ribi::QtQuadBezierArrowItem::m_click_easy_width = 10.0; ribi::QtQuadBezierArrowItem::QtQuadBezierArrowItem(   QGraphicsItem* const from,   const bool tail,   QGraphicsItem* const mid,   const bool head,   QGraphicsItem* const to,   QGraphicsItem* parent ) noexcept   : QGraphicsItem(parent),     m_signal_item_updated{},     m_focus_pen{QPen(Qt::DashLine)},     m_from{from},     m_head{head},     m_mid{mid},     m_pen{QPen(QColor(0,0,0))},     m_show_bounding_rect{true},     m_tail{tail},     m_to{to} {   #ifndef NDEBUG   Test();   #endif   assert(from);   assert(to);   assert((mid || !mid) && "No mid results in a straight arrow");   assert(from != to);   assert(from != mid);   assert(mid != to);   this->setFlags(       QGraphicsItem::ItemIsFocusable     | QGraphicsItem::ItemIsSelectable   );   assert(!(flags() & QGraphicsItem::ItemIsMovable) );   assert( (flags() & QGraphicsItem::ItemIsSelectable) );   this->setAcceptHoverEvents(true);   //Put this arrow item under the rect   if (mid) { setZValue(mid->zValue() - 1.0); } } QRectF ribi::QtQuadBezierArrowItem::boundingRect() const {   return shape().boundingRect(); } QPointF ribi::QtQuadBezierArrowItem::GetBeyond() const noexcept {   const QPointF center = GetCenter();   const double dx_mid_center = GetMidItem() ? (GetMidItem()->pos().x() - center.x()) : 0.0;   const double dy_mid_center = GetMidItem() ? (GetMidItem()->pos().y() - center.y()) : 0.0;   const QPointF beyond(center.x() + dx_mid_center + dx_mid_center, center.y() + dy_mid_center + dy_mid_center);   return beyond; } QPointF ribi::QtQuadBezierArrowItem::GetCenter() const noexcept {   const QPointF center(GetToItem()->pos() + GetFromItem()->pos() / 2.0);   return center; } QPointF ribi::QtQuadBezierArrowItem::GetHead() const noexcept {   typedef boost::geometry::model::d2::point_xy Point;   typedef boost::geometry::model::linestring Line;   typedef boost::geometry::model::box Rect;   //const bool debug = true;   const QPointF beyond = GetBeyond();   const Line line_head = CreateLine(     std::vector(       {         Point(beyond.x(),beyond.y()),         Point(m_to->pos().x(),m_to->pos().y()),       }     )   );   const QRectF qr_to = m_to->boundingRect().translated(m_to->pos());   const Rect r_to(     Point(qr_to.topLeft().x()    ,qr_to.topLeft().y()    ),     Point(qr_to.bottomRight().x(),qr_to.bottomRight().y())     );   std::vector p_head_end = GetLineRectIntersections(line_head,r_to);   if (p_head_end.size() == 1)   {     return QPointF(p_head_end[0].x(),p_head_end[0].y());   }   if (p_head_end.empty())   {     p_head_end.push_back(Point(m_to->pos().x(),m_to->pos().y()));     //Yes,it happens, when the line does not leave the rectangle     //this happens when the two node rectanges overlap     assert(!p_head_end.empty());     assert(p_head_end.size() == 1); ///BUG? claudio does not think this is a bug:                                     ///one element is added two lines above     return QPointF(p_head_end[0].x(),p_head_end[0].y());   }   else   {     assert(p_head_end.size() == 2);     //Choose point closest to beyond     const double d1 = Geometry().GetDistance(beyond.x(),beyond.y(),p_head_end[0].x(),p_head_end[0].y());     const double d2 = Geometry().GetDistance(beyond.x(),beyond.y(),p_head_end[1].x(),p_head_end[1].y());     if (d1 <= d2)     {       return QPointF(p_head_end[0].x(),p_head_end[0].y());     }     else     {       return QPointF(p_head_end[1].x(),p_head_end[1].y());     }   } } QPointF ribi::QtQuadBezierArrowItem::GetTail() const noexcept {   typedef boost::geometry::model::d2::point_xy Point;   typedef boost::geometry::model::linestring Line;   typedef boost::geometry::model::box Rect;   const QPointF beyond = GetBeyond();   const Line line_tail = CreateLine(     std::vector(       {         Point(m_from->pos().x(),m_from->pos().y()),         Point(beyond.x(),beyond.y()),       }     )   );   const QRectF qr_from = m_from->boundingRect().translated(m_from->pos());   const Rect r_from(     Point(qr_from.topLeft().x()    ,qr_from.topLeft().y()    ),     Point(qr_from.bottomRight().x(),qr_from.bottomRight().y())     );   std::vector p_tail_end = GetLineRectIntersections(line_tail,r_from);   if (p_tail_end.size() == 1)   {     return QPointF(p_tail_end[0].x(),p_tail_end[0].y());   }   if (p_tail_end.empty())   {     //Yes,it happens, when the line does not leave the rectangle     //this happens when the two node rectanges overlap     p_tail_end.push_back(Point(m_from->pos().x(),m_from->pos().y()));     assert(!p_tail_end.empty());     assert(p_tail_end.size() == 1);     return QPointF(p_tail_end[0].x(),p_tail_end[0].y());   }   else   {     assert(p_tail_end.size() == 2);     //Choose point closest to beyond     const double d1 = Geometry().GetDistance(beyond.x(),beyond.y(),p_tail_end[0].x(),p_tail_end[0].y());     const double d2 = Geometry().GetDistance(beyond.x(),beyond.y(),p_tail_end[1].x(),p_tail_end[1].y());     if (d1 <= d2)     {       return QPointF(p_tail_end[0].x(),p_tail_end[0].y());     }     else     {       return QPointF(p_tail_end[1].x(),p_tail_end[1].y());     }   } } std::string ribi::QtQuadBezierArrowItem::GetVersion() noexcept {   return "1.5"; } std::vector ribi::QtQuadBezierArrowItem::GetVersionHistory() noexcept {   return {     "2012-12-07: version 1.0: initial version",     "2012-12-13: version 1.1: respond to focus",     "2012-12-29: version 1.2: fixed bug in GetHead and GetTail that occurs when GetLineRectIntersections returns two points",     "2013-01-01: version 1.3: added QGraphicsItem getters",     "2013-07-10: version 1.4: setting arrow heads emits a notification signal",     "2014-03-18: version 1.5: allow arrow to be straight"   }; } void ribi::QtQuadBezierArrowItem::hoverEnterEvent(QGraphicsSceneHoverEvent *) noexcept {   this->setCursor(QCursor(Qt::PointingHandCursor)); } void ribi::QtQuadBezierArrowItem::hoverMoveEvent(QGraphicsSceneHoverEvent *) noexcept {   this->setCursor(QCursor(Qt::PointingHandCursor)); } void ribi::QtQuadBezierArrowItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) noexcept {   this->setCursor(QCursor(Qt::PointingHandCursor)); } void ribi::QtQuadBezierArrowItem::keyPressEvent(QKeyEvent *event) noexcept {   switch (event->key())   {     case Qt::Key_F1:     case Qt::Key_1:     case Qt::Key_T:     case Qt::Key_Minus:       SetHasTail(!HasTail());       return;     case Qt::Key_F2:     case Qt::Key_2:     case Qt::Key_H:     case Qt::Key_Plus:       SetHasHead(!HasHead());       return;     default:       break;   }   QGraphicsItem::keyPressEvent(event); } void ribi::QtQuadBezierArrowItem::mousePressEvent(QGraphicsSceneMouseEvent *event) noexcept {   if (event->modifiers() & Qt::ShiftModifier)   {     if ((event->pos() - this->m_from->pos()).manhattanLength() < 10.0)     {       SetHasTail(!HasTail());     }     else if ((event->pos() - this->m_to->pos()).manhattanLength() < 10.0)     {       SetHasHead(!HasHead());     }   }   QGraphicsItem::mousePressEvent(event); } void ribi::QtQuadBezierArrowItem::paint(QPainter* painter, const QStyleOptionGraphicsItem *, QWidget *) noexcept {   painter->setRenderHint(QPainter::Antialiasing);   if (this->isSelected() || this->hasFocus())   {     painter->setPen(m_focus_pen);   }   else   {     painter->setPen(m_pen);   }   //Line must go _though_ mid pos, instead of using it as a virtual hinge point   //Solution:   // - define point 'center' as the middle between from and to   // - define point 'beyond' as the mirror point of 'center', using mid_pos as a mirror   const QPointF p_end_head{GetHead()};   const QPointF p_end_tail{GetTail()};   const QPointF p_center((p_end_tail + p_end_head) / 2.0);   const double dx_mid_center = GetMidItem() ? (GetMidItem()->pos().x() - p_center.x()) : 0.0;   const double dy_mid_center = GetMidItem() ? (GetMidItem()->pos().y() - p_center.y()) : 0.0;   const QPointF p_beyond(p_center.x() + dx_mid_center + dx_mid_center, p_center.y() + dy_mid_center + dy_mid_center);   QPainterPath curve;   curve.moveTo(p_end_tail);   curve.quadTo(p_beyond,p_end_head);   painter->drawPath(curve);   if (GetMidItem())   {     painter->drawEllipse(GetMidItem()->pos(),1,1);   }   {     const double sz = 10.0; //pixels     if (m_tail)     {       //The angle from midpoint to tail       //Thanks goes out to Toine van den Bogaart and Theo van den Bogaart for being happy to help with the math       const double pi{boost::math::constants::pi()};       //#define USE_RICHEL_EDIT_20141204       #ifdef USE_RICHEL_EDIT_20141204       const double dx{p_beyond.x() - m_from->pos().x()};       const double dy{p_beyond.y() - m_from->pos().y()};       const double arrowangle{0.1*pi};       double angle1{0.5*pi + arrowangle - Geometry().GetAngleClockScreen(-dx,-dy)};       double angle2{0.5*pi + arrowangle - Geometry().GetAngleClockScreen(-dx,-dy)};       #endif // USE_RICHEL_EDIT_20141204       #define USE_CLAUDIO_EDIT_20141205       #ifdef USE_CLAUDIO_EDIT_20141205       const double dx{p_end_tail.x() - p_beyond.x()};       const double dy{p_end_tail.y() - p_beyond.y()};       double angle1{0.6*pi - Geometry().GetAngleClockScreen(-dx,-dy)};       double angle2{0.4*pi - Geometry().GetAngleClockScreen(-dx,-dy)};       #endif // USE_CLAUDIO_EDIT_20141205       //#define USE_RICHEL_EDIT_20150209       #ifdef USE_RICHEL_EDIT_20150209       const double dx{p_end_tail.x() - p_beyond.x()};       const double dy{p_end_tail.y() - p_beyond.y()};       double angle1{0.5*pi - Geometry().GetAngleClockScreen(-dx,-dy)};       double angle2{0.5*pi - Geometry().GetAngleClockScreen(-dx,-dy)};       #endif       const QPointF p0{p_end_tail.x(),p_end_tail.y()};       #ifdef USE_RICHEL_2014       const QPointF p1         = p0 + QPointF(            std::cos(angle1) * sz,            -std::sin(angle1) * sz);       const QPointF p2         = p0 + QPointF(            std::cos(angle2) * sz,            -std::sin(angle2) * sz);       #else // USE_RICHEL_2014       const QPointF p1         = p0 + QPointF(            std::sin(angle1) * sz,            -std::cos(angle1) * sz);       const QPointF p2         = p0 + QPointF(            std::sin(angle2) * sz,            -std::cos(angle2) * sz);       #endif // USE_ORIGINAL       painter->drawPolygon(QPolygonF() << p0 << p1 << p2);     }     if (m_head)     {       //The angle from midpoint to head       //Thanks goes out to Toine van den Bogaart and Theo van den Bogaart for being happy to help with the math       const double pi{boost::math::constants::pi()};       const double dx{p_end_head.x() - p_beyond.x()};       const double dy{(p_end_head.y() - p_beyond.y())};       double angle1{0.6*pi - Geometry().GetAngleClockScreen(-dx,-dy)};       double angle2{0.4*pi - Geometry().GetAngleClockScreen(-dx,-dy)};       const QPointF p0(p_end_head.x(),p_end_head.y());       const QPointF p1         = p0 + QPointF(            std::cos(angle1) * sz,            -std::sin(angle1) * sz);       const QPointF p2         = p0 + QPointF(            std::cos(angle2) * sz,            -std::sin(angle2) * sz);       painter->drawPolygon(QPolygonF() << p0 << p1 << p2);     }   }   if (m_show_bounding_rect)   {     const QPen prev_pen = painter->pen();     const QBrush prev_brush = painter->brush();     painter->setPen(QPen(QColor(0,0,96)));     painter->setBrush(QBrush(QColor(0,0,255,64)));     painter->drawRect(this->boundingRect().adjusted(1.0,1.0,-1.0,-1.0));     painter->setPen(prev_pen);     painter->setBrush(prev_brush);   } } void ribi::QtQuadBezierArrowItem::SetFocusPen(const QPen& pen) noexcept {   if (m_focus_pen != pen)   {     m_focus_pen = pen;     this->update();     m_signal_item_updated(this);   } } void ribi::QtQuadBezierArrowItem::SetFromPos(const QPointF& pos) noexcept {   assert(m_from);   if (m_from->pos() != pos)   {     m_from->setPos(pos);     this->update();     m_signal_item_updated(this);   } } void ribi::QtQuadBezierArrowItem::SetHasHead(const bool has_head) noexcept {   if (m_head != has_head)   {     m_head = has_head;     this->update();     m_signal_item_updated(this);   } } void ribi::QtQuadBezierArrowItem::SetHasTail(const bool has_tail) noexcept {   if (m_tail != has_tail)   {     m_tail = has_tail;     this->update();     m_signal_item_updated(this);   } } void ribi::QtQuadBezierArrowItem::SetMidPos(const QPointF& pos) noexcept {   assert(m_mid);   if (m_mid->pos() != pos)   {     m_mid->setPos(pos);     this->update();     m_signal_item_updated(this);   } } void ribi::QtQuadBezierArrowItem::SetPen(const QPen& pen) noexcept {   if (m_pen != pen)   {     m_pen = pen;     this->update();     m_signal_item_updated(this);   } } void ribi::QtQuadBezierArrowItem::SetToPos(const QPointF& pos) noexcept {   assert(m_to);   if (m_to->pos() != pos)   {     m_to->setPos(pos);     this->update();     m_signal_item_updated(this);   } } QPainterPath ribi::QtQuadBezierArrowItem::shape() const noexcept {   const QPointF p_end_tail = GetHead();   const QPointF p_end_head = GetTail();   const QPointF p_center((p_end_tail + p_end_head) / 2.0);   const double dx_mid_center = GetMidItem() ? (GetMidItem()->pos().x() - p_center.x()) : 0.0;   const double dy_mid_center = GetMidItem() ? (GetMidItem()->pos().y() - p_center.y()) : 0.0;   const QPointF p_beyond(p_center.x() + dx_mid_center + dx_mid_center, p_center.y() + dy_mid_center + dy_mid_center);   QPainterPath curve;   curve.moveTo(p_end_tail);   curve.quadTo(p_beyond,p_end_head);   QPainterPathStroker stroker;   stroker.setWidth(m_click_easy_width);   return stroker.createStroke(curve); } #ifndef NDEBUG void ribi::QtQuadBezierArrowItem::Test() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     Geometry();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   /*   //Render one QtQuadBezierArrowItem   {     std::unique_ptr my_scene{new QGraphicsScene};     std::vector rects;     const int n_items = 3;     const double ray = 100;     for (int i=0; i!=n_items; ++i)     {       const double pi = boost::math::constants::pi();       const double angle = 2.0 * pi * (static_cast(i) / static_cast(n_items));       const double x1 =  std::sin(angle) * ray;       const double y1 = -std::cos(angle) * ray;       QGraphicsRectItem * const rect = new QGraphicsRectItem;       rect->setRect(-8.0,-4.0,16.0,8.0);       rect->setPos(x1,y1);       assert(!rect->scene());       my_scene->addItem(rect);       rects.push_back(rect);     }     for (int i=0; iscene());       my_scene->addItem(item);     }     QGraphicsScene().render(     //my_scene->     QGraphicsScene q;   }   */ } #endif std::ostream& ribi::operator<<(std::ostream& os, const QtQuadBezierArrowItem& arrow) noexcept {   os     << '(' << arrow.m_from->x() << ',' << arrow.m_from->y() << ')'     << (arrow.m_tail ? '<' : '-') << "-- "     << '(' << arrow.m_mid->x() << ',' << arrow.m_mid->y() << ')'     << " --" << (arrow.m_head ? '>' : '-') << ' '     << '(' << arrow.m_to->x() << ',' << arrow.m_to->y() << ')'   ;   return os; } bool ribi::operator==(const QtQuadBezierArrowItem& lhs, const QtQuadBezierArrowItem& rhs) noexcept {   return        lhs.GetFocusPen() == rhs.GetFocusPen()     && lhs.GetFromItem() == rhs.GetFromItem()     && lhs.HasHead() == rhs.HasHead()     && lhs.GetMidItem() == rhs.GetMidItem()     && lhs.GetPen() == rhs.GetPen()     && lhs.HasTail() == rhs.HasTail()     && lhs.GetToItem() == rhs.GetToItem()   ; }` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -  - +Code is maintained at [https://github.com/richelbilderbeek/RibiClasses/tree/master/CppQtQuadBezierArrowItem](https://github.com/richelbilderbeek/RibiClasses/tree/master/CppQtQuadBezierArrowItem). diff --git a/content/CppScope.md b/content/CppScope.md index ce30c041..1011e45d 100644 --- a/content/CppScope.md +++ b/content/CppScope.md @@ -82,46 +82,18 @@ an enclosing scope \[7,12\].   -1. [Herb Sutter](CppHerbSutter.md), [Andrei - Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 - rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 10: - 'Minimize global and shared data'. -2. [Herb Sutter](CppHerbSutter.md), [Andrei - Alexandrescu](CppAndreiAlexandrescu.md) . C++ coding standards: 101 - rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 18: - 'Declare variables as locally as possible'. -3. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (3rd edition).ISBN: 0-201-88954-4. Chapter 1.8.2.a: 'Don't - use global data (use members)' -4. [Jarrod Hollingworth](CppJarrodHollingworth.md) , Bob Swart, Mark - Cashman, Paul Gustavson. Sams C++ Builder 6 Developer's Guide. - ISBN: 0-672-32480-6. Chapter 3: 'Avoid using global variables' -5. [Jesse Liberty](CppJesseLiberty.md) . Sams teach yourself C++ in - 24 hours. ISBN: 0-672-32224-2. Hour 5, paragraph 'Global variables': - 'In C++, global variables are avoided because they can create very - confusing code that is hard to maintain.' -6. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (3rd edition). 1997. ISBN: 0-201-88954-4. Item 4.10.1: - 'Keep scopes small'. -7. [Bjarne Stroustrup](CppBjarneStroustrup.md) . The C++ Programming - Language (3rd edition). 1997. ISBN: 0-201-88954-4. Item 4.10.2: - 'Don't use the same name in both a scope and an enclosing scope'. -8. Stephen C. Dewhurst. C++ Gotchas. 2003. ISBN: 0-321-12518-5. Gotcha - \#3: 'Avoid global variables'. -9. [C++ FAQ Lite](http://www.parashift.com/c++-faq/global-vars.html): - 'The names of global variables should start with //' and 'Instead of - using a global variable, you should seriously consider if there are - ways to limit the variable's visibility and/or lifetime'. -10. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (4th edition). 2013. ISBN: 978-0-321-56384-2. - Chapter 6.3.4. Scope, page 157 -11. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 6.6. - Advice. page 169: '\[17\] Keep scopes small' -12. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 6.6. - Advice. page 169: '\[18\] Don't use the same name in both a scope - and its enclosing scope' +1. [Herb Sutter](CppHerbSutter.md), [Andrei Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 10: 'Minimize global and shared data'. +2. [Herb Sutter](CppHerbSutter.md), [Andrei Alexandrescu](CppAndreiAlexandrescu.md) . C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 18: 'Declare variables as locally as possible'. +3. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (3rd edition).ISBN: 0-201-88954-4. Chapter 1.8.2.a: 'Don't use global data (use members)' +4. [Jarrod Hollingworth](CppJarrodHollingworth.md) , Bob Swart, Mark Cashman, Paul Gustavson. Sams C++ Builder 6 Developer's Guide. ISBN: 0-672-32480-6. Chapter 3: 'Avoid using global variables' +5. [Jesse Liberty](CppJesseLiberty.md) . Sams teach yourself C++ in 24 hours. ISBN: 0-672-32224-2. Hour 5, paragraph 'Global variables': 'In C++, global variables are avoided because they can create very confusing code that is hard to maintain.' +6. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (3rd edition). 1997. ISBN: 0-201-88954-4. Item 4.10.1: 'Keep scopes small'. +7. [Bjarne Stroustrup](CppBjarneStroustrup.md) . The C++ Programming Language (3rd edition). 1997. ISBN: 0-201-88954-4. Item 4.10.2: 'Don't use the same name in both a scope and an enclosing scope'. +8. Stephen C. Dewhurst. C++ Gotchas. 2003. ISBN: 0-321-12518-5. Gotcha \#3: 'Avoid global variables'. +9. [C++ FAQ Lite](https://isocpp.org/wiki/faq/coding-standards#global-vars): 'The names of global variables should start with //' and 'Instead of using a global variable, you should seriously consider if there are ways to limit the variable's visibility and/or lifetime'. +10. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 6.3.4. Scope, page 157 +11. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 6.6. Advice. page 169: '\[17\] Keep scopes small' +12. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 6.6. Advice. page 169: '\[18\] Don't use the same name in both a scope and its enclosing scope'   diff --git a/content/CppState.md b/content/CppState.md index 12cd3685..61f21a3d 100644 --- a/content/CppState.md +++ b/content/CppState.md @@ -16,12 +16,9 @@ [state/State](CppState.md) has multiple meanings: -- [state](CppState.md): the size of the state space of a piece of - code -- [state](CppState.md): the current position in state space of a - piece of code -- [State](CppDesignPatternState.md): a [Design - Pattern](CppDesignPattern.md) +- [state](CppState.md): the size of the state space of a piece of code +- [state](CppState.md): the current position in state space of a piece of code +- [State](CppDesignPatternState.md): a [Design Pattern](CppDesignPattern.md)   @@ -101,36 +98,15 @@ Pattern](CppDesignPattern.md)).   -1. [Herb Sutter](CppHerbSutter.md), [Andrei - Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 - rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 10: - 'Minimize global and shared data'. -2. [Herb Sutter](CppHerbSutter.md), [Andrei - Alexandrescu](CppAndreiAlexandrescu.md) . C++ coding standards: 101 - rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 18: - 'Declare variables as locally as possible'. -3. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (3rd edition).ISBN: 0-201-88954-4. Chapter 1.8.2.a: 'Don't - use global data (use members)' -4. [Jarrod Hollingworth](CppJarrodHollingworth.md) , Bob Swart, Mark - Cashman, Paul Gustavson. Sams C++ Builder 6 Developer's Guide. - ISBN: 0-672-32480-6. Chapter 3: 'Avoid using global variables' -5. [Jesse Liberty](CppJesseLiberty.md) . Sams teach yourself C++ in - 24 hours. ISBN: 0-672-32224-2. Hour 5, paragraph 'Global variables': - 'In C++, global variables are avoided because they can create very - confusing code that is hard to maintain.' -6. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (3rd edition). 1997. ISBN: 0-201-88954-4. Item 4.10.1: - 'Keep scopes small'. -7. [Bjarne Stroustrup](CppBjarneStroustrup.md) . The C++ Programming - Language (3rd edition). 1997. ISBN: 0-201-88954-4. Item 4.10.2: - 'Don't use the same name in both a scope and an enclosing scope'. -8. Stephen C. Dewhurst. C++ Gotchas. 2003. ISBN: 0-321-12518-5. Gotcha - \#3: 'Avoid global variables'. -9. [C++ FAQ Lite](http://www.parashift.com/c++-faq/global-vars.html): - 'The names of global variables should start with //' and 'Instead of - using a global variable, you should seriously consider if there are - ways to limit the variable's visibility and/or lifetime'. +1. [Herb Sutter](CppHerbSutter.md), [Andrei Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 10: 'Minimize global and shared data'. +2. [Herb Sutter](CppHerbSutter.md), [Andrei Alexandrescu](CppAndreiAlexandrescu.md) . C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 18: 'Declare variables as locally as possible'. +3. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (3rd edition).ISBN: 0-201-88954-4. Chapter 1.8.2.a: 'Don't use global data (use members)' +4. [Jarrod Hollingworth](CppJarrodHollingworth.md) , Bob Swart, Mark Cashman, Paul Gustavson. Sams C++ Builder 6 Developer's Guide. ISBN: 0-672-32480-6. Chapter 3: 'Avoid using global variables' +5. [Jesse Liberty](CppJesseLiberty.md) . Sams teach yourself C++ in 24 hours. ISBN: 0-672-32224-2. Hour 5, paragraph 'Global variables': 'In C++, global variables are avoided because they can create very confusing code that is hard to maintain.' +6. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (3rd edition). 1997. ISBN: 0-201-88954-4. Item 4.10.1: 'Keep scopes small'. +7. [Bjarne Stroustrup](CppBjarneStroustrup.md) . The C++ Programming Language (3rd edition). 1997. ISBN: 0-201-88954-4. Item 4.10.2: 'Don't use the same name in both a scope and an enclosing scope'. +8. Stephen C. Dewhurst. C++ Gotchas. 2003. ISBN: 0-321-12518-5. Gotcha \#3: 'Avoid global variables'. +9. [C++ FAQ Lite](https://isocpp.org/wiki/faq/coding-standards#global-vars): 'The names of global variables should start with //' and 'Instead of using a global variable, you should seriously consider if there are ways to limit the variable's visibility and/or lifetime'.   diff --git a/content/CppStk.md b/content/CppStk.md index 1520d1be..73fa5a7c 100644 --- a/content/CppStk.md +++ b/content/CppStk.md @@ -1,214 +1,62 @@ - -  - -  - -  - -  - -  - -([C++](Cpp.md)) [STK](CppStk.md) -================================== - -  - -  +# ([C++](Cpp.md)) [STK](CppStk.md) The [STK](CppStk.md) (abbreviation for 'Systhesis ToolKit') is a free [C++](Cpp.md) [audio](CppAudio.md) [library](CppLibrary.md). -  - -  - -  - -  - -  - -![Lubuntu](PicLubuntu.png)![Ubuntu](PicUbuntu.png) Installing the [STK](CppStk.md) ------------------------------------------------------------------------------------ - -  +## ![Lubuntu](PicLubuntu.png)![Ubuntu](PicUbuntu.png) Installing the [STK](CppStk.md) Under [Ubuntu](CppUbuntu.md) and [Lubuntu](CppLubuntu.md), the [STK](CppStk.md) can be installed from Ubuntu's Software Center: -  - - ------------------------------------- - ` sudo apt-get install libstk0-dev` - ------------------------------------- - -  - -  - -  - -  - -  - -![Qt Creator](PicQtCreator.png) Adding [STK](CppStk.md) to the [project file](CppQtProjectFile.md) ----------------------------------------------------------------------------------------------------- - -  +``` +sudo apt-get install libstk0-dev +``` +## ![Qt Creator](PicQtCreator.png) Adding [STK](CppStk.md) to the [project file](CppQtProjectFile.md) In [Qt Creator](CppQtCreator.md), to be able to use the [STK](CppStk.md), add the following lines to your [project file](CppQtProjectFile.md): -  - - ----------------------------------------------------------------------- - ` INCLUDEPATH += /usr/include/stk LIBS += -L/usr/lib -lstk -lrtaudio` - ----------------------------------------------------------------------- - -  +``` +INCLUDEPATH += /usr/include/stk LIBS += -L/usr/lib -lstk -lrtaudio +``` Thanks to Michael Jenkinson for his '-lrtaudio' suggestion in the [project file](CppQtProjectFile.md). -  - -  - -  - -  - -  - -![Qt Creator](PicQtCreator.png) [STK](CppStk.md) examples ----------------------------------------------------------- - -  +## ![Qt Creator](PicQtCreator.png) [STK](CppStk.md) examples - [STK example 1: beep](CppStkExample1.md) - [STK example 2: random beeps](CppStkExample2.md) -  - -  - -  - -  - -  - -Critique on [STK](CppStk.md) ------------------------------ - -  +## Critique on [STK](CppStk.md) The [STK](CppStk.md) is the only [audio](CppAudio.md) [library](CppLibrary.md) I got to produce beeps from source code. -  - It hurts me that I have much critique on the coding style of the [STK](CppStk.md): -1. The [STK](CppStk.md) is not [const correct](CppConstCorrect.md). - One should use [const](CppConst.md) whenever - possible/feasible \[1\]\[2\]\[3\]\[4\]\[5\]\[6\]. One should be - [const correct](CppConstCorrect.md) \[7\]\[8\]\[9\]\[10\]. -2. The [STK](CppStk.md) uses the [keyword](CppKeyword.md) - [register](CppRegister.md). In this case, one should not use - [register](CppRegister.md) \[11\]. -3. The [STK](CppStk.md) uses C-style [casts](CppCast.md). One should - use C++ style [casts](CppCast.md) \[12\]\[13\]. - -  - -  +1. The [STK](CppStk.md) is not [const correct](CppConstCorrect.md). One should use [const](CppConst.md) whenever possible/feasible \[1\]\[2\]\[3\]\[4\]\[5\]\[6\]. One should be [const correct](CppConstCorrect.md) \[7\]\[8\]\[9\]\[10\]. +2. The [STK](CppStk.md) uses the [keyword](CppKeyword.md) [register](CppRegister.md). In this case, one should not use [register](CppRegister.md) \[11\]. +3. The [STK](CppStk.md) uses C-style [casts](CppCast.md). One should use C++ style [casts](CppCast.md) \[12\]\[13\]. -  - -  - -  - -External links --------------- - -  +## External links - [STK homepage](https://ccrma.stanford.edu/software/stk/index.html) -  - -  - -  - -  - -  - -[References](CppReferences.md) -------------------------------- - -  - -1. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (3rd edition). ISBN: 0-201-88954-4 7.9.3: 'Use const - extensively and consistently'. -2. [Scott Meyers](CppScottMeyers.md). Effective C++ (3rd - edition).ISBN: 0-321-33487-6. Item 3: 'Use const whenever possible'. -3. [Jarrod Hollingworth](CppJarrodHollingworth.md), [Bob - Swart](CppBobSwart.md), [Mark Cashman](CppMarkCashman.md), [Paul - Gustavson](CppPaulGustavson.md). Sams C++ Builder 6 - Developer's Guide. ISBN: 0-672-32480-6. Chapter 3: 'Understand and - use const in your code'. -4. [Jesse Liberty](CppJesseLiberty.md). Sams teach yourself C++ in - 24 hours. ISBN: 0-672-32224-2. Hour 8, chapter 'Const member - functions': 'Use const whenever possible.'. -5. [Scott Meyers](CppScottMeyers.md). Effective C++ (3rd edition). - ISBN: 0-321-33487-6. Item 2: 'Prefer consts, enums and inlines - to \#defines'. -6. [Herb Sutter](CppHerbSutter.md), [Andrei - Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 - rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 15: - 'Use const proactively'. -7. [Herb Sutter](CppHerbSutter.md). Exceptional C++ style. 2005. - ISBN: 0-201-76042-8. Item 1 guideline: 'Be const correct'. -8. [Marshall Cline](CppMarshallCline.md), [Greg - Lomow](CppGregLomow.md) and [Mike Girou](CppMikeGirou.md). - C++ FAQs. ISBN: 0-201-3098301. FAQ 14.05: 'Is const correctness - tedious?' (Answer: no). -9. [The C++ FAQ - Lite](http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.1). - Item 18.1: What is 'const correctness' (Answer: 'A good thing')? -10. [Bruce Eckel](CppBruceEckel.md). Thinking in C++, second edition, - volume 1. 2000. ISBN: 0-13-979809-9. Item 8: 'Constants', paragraph - 'Summary': 'const-correctness can be a lifesaver for projects'. -11. [Herb Sutter](CppHerbSutter.md). Exceptional C++ style. 2005. - ISBN: 0-201-76042-8. Item 28 guideline: 'Never write - register \[...\]'. -12. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming - Language (3rd edition). ISBN: 0-201-88954-4 6.5.5: 'When explicit - type conversion is necessary, prefer the more specific cast - operators to the C-style cast'. -13. [Herb Sutter](CppHerbSutter.md), [Andrei - Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 - rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 95: - 'Don't use C-style casts'. - -  - -  - -  - -  - -  - -  - +## [References](CppReferences.md) + +1. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (3rd edition). ISBN: 0-201-88954-4 7.9.3: 'Use const extensively and consistently'. +2. [Scott Meyers](CppScottMeyers.md). Effective C++ (3rd edition).ISBN: 0-321-33487-6. Item 3: 'Use const whenever possible'. +3. [Jarrod Hollingworth](CppJarrodHollingworth.md), [Bob Swart](CppBobSwart.md), [Mark Cashman](CppMarkCashman.md), [Paul Gustavson](CppPaulGustavson.md). Sams C++ Builder 6 Developer's Guide. ISBN: 0-672-32480-6. Chapter 3: 'Understand and use const in your code'. +4. [Jesse Liberty](CppJesseLiberty.md). Sams teach yourself C++ in 24 hours. ISBN: 0-672-32224-2. Hour 8, chapter 'Const member functions': 'Use const whenever possible.'. +5. [Scott Meyers](CppScottMeyers.md). Effective C++ (3rd edition). ISBN: 0-321-33487-6. Item 2: 'Prefer consts, enums and inlines to \#defines'. +6. [Herb Sutter](CppHerbSutter.md), [Andrei Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 15: 'Use const proactively'. +7. [Herb Sutter](CppHerbSutter.md). Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Be const correct'. +8. [Marshall Cline](CppMarshallCline.md), [Greg Lomow](CppGregLomow.md) and [Mike Girou](CppMikeGirou.md). C++ FAQs. ISBN: 0-201-3098301. FAQ 14.05: 'Is const correctness tedious?' (Answer: no). +9. [The C++ FAQ Lite](https://isocpp.org/wiki/faq/const-correctness#overview-const). Item 18.1: What is 'const correctness' (Answer: 'A good thing')? +10. [Bruce Eckel](CppBruceEckel.md). Thinking in C++, second edition, volume 1. 2000. ISBN: 0-13-979809-9. Item 8: 'Constants', paragraph 'Summary': 'const-correctness can be a lifesaver for projects'. +11. [Herb Sutter](CppHerbSutter.md). Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 28 guideline: 'Never write register \[...\]'. +12. [Bjarne Stroustrup](CppBjarneStroustrup.md). The C++ Programming Language (3rd edition). ISBN: 0-201-88954-4 6.5.5: 'When explicit type conversion is necessary, prefer the more specific cast operators to the C-style cast'. +13. [Herb Sutter](CppHerbSutter.md), [Andrei Alexandrescu](CppAndreiAlexandrescu.md). C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 95: 'Don't use C-style casts'. diff --git a/content/CppToDouble.md b/content/CppToDouble.md index 5f17e19b..6683c924 100644 --- a/content/CppToDouble.md +++ b/content/CppToDouble.md @@ -71,7 +71,7 @@ To [conversion](CppConvert.md) a [std::string](CppStdString.md) to any The implementation below is similar to [the C++ FAQ Lite's convertToDouble code -snippet](http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2). +snippet](https://isocpp.org/wiki/faq/misc-technical-issues#convert-num-to-string).   diff --git a/content/CppUnits.md b/content/CppUnits.md index 4f76cfce..728b5498 100644 --- a/content/CppUnits.md +++ b/content/CppUnits.md @@ -1,546 +1,3 @@ +# ([C++](Cpp.md)) [Units](CppUnits.md) -  - -  - -  - -  - -  - -([C++](Cpp.md)) [Units](CppUnits.md) -====================================== - -  - -Technical facts ---------------- - -  - -  - -  - -  - -  - -  - -./CppUnits/CppUnits.pri ------------------------ - -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` INCLUDEPATH += \     ../../Classes/CppUnits SOURCES += \     ../../Classes/CppUnits/units.cpp \     ../../Classes/CppUnits/sulfidemoleculeamount.cpp \     ../../Classes/CppUnits/hydrogenmoleculeamount.cpp \     ../../Classes/CppUnits/speciesdensity.cpp \     ../../Classes/CppUnits/moleculeamount.cpp \     ../../Classes/CppUnits/volumetricflow.cpp \     ../../Classes/CppUnits/massflow.cpp \     ../../Classes/CppUnits/massdensity.cpp \     ../../Classes/CppUnits/concentration.cpp \     ../../Classes/CppUnits/speciesgrowth.cpp \     ../../Classes/CppUnits/rate.cpp \     ../../Classes/CppUnits/concentrationchange.cpp \     ../../Classes/CppUnits/ribi_time.cpp HEADERS  += \     ../../Classes/CppUnits/units.h \     ../../Classes/CppUnits/moleculeamount.h \     ../../Classes/CppUnits/sulfidemoleculeamount.h \     ../../Classes/CppUnits/hydrogenmoleculeamount.h \     ../../Classes/CppUnits/speciesdensity.h \     ../../Classes/CppUnits/volumetricflow.h \     ../../Classes/CppUnits/massflow.h \     ../../Classes/CppUnits/massdensity.h \     ../../Classes/CppUnits/concentration.h \     ../../Classes/CppUnits/speciesgrowth.h \     ../../Classes/CppUnits/rate.h \     ../../Classes/CppUnits/concentrationchange.h \     ../../Classes/CppUnits/ribi_time.h OTHER_FILES += \     ../../Classes/CppUnits/Licence.txt` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/concentration.h --------------------------- - -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef CONCENTRATION_H #define CONCENTRATION_H ///Mole per cubic meter #include namespace boost {   namespace units {     using concentration_dimension       = derived_dimension<         amount_base_dimension,1,         length_base_dimension,-3       >::type;   } // ~namespace units } // ~namespace boost namespace boost {   namespace units {     namespace si {       using concentration = unit;       BOOST_UNITS_STATIC_CONSTANT(mol_per_cubic_meter,concentration);       BOOST_UNITS_STATIC_CONSTANT(mole_per_cubic_meter,concentration);       using Concentration = boost::units::quantity;       std::istream& operator>>(std::istream& is,Concentration& sd);     } // ~namespace si   } // ~namespace units } // ~namespace boost namespace ribi {   namespace units {     using Concentration = boost::units::si::Concentration;     #ifndef NDEBUG     void TestConcentration() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // CONCENTRATION_H` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/concentration.cpp ----------------------------- - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include "concentration.h" #include #include #include #include #include #include "fileio.h" #include "testtimer.h" std::istream& boost::units::si::operator>>(std::istream& is, Concentration& sd) {   double value = 0.0;   is >> value;   std::string unit;   is >> unit;   assert(unit == "m^-3");   is >> unit;   assert(unit == "mol");   sd = Concentration(value * boost::units::si::mole / boost::units::si::cubic_meter);   return is; } #ifndef NDEBUG void ribi::units::TestConcentration() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     ribi::fileio::FileIo();   }   const ribi::TestTimer test_timer(__func__,__FILE__,1.0);   using ribi::fileio::FileIo;   using Concentration = boost::units::quantity;   //Concentration is in species per square meter   {     const Concentration d{       1.0 * boost::units::si::mole / boost::units::si::cubic_meter     };     std::stringstream s;     s << d;     const std::string t{s.str()};     std::cerr << t << std::endl;     assert(t.substr(t.size() - 8, 8) == "m^-3 mol");   }   //Concentration uses a dot as a seperator   {     const Concentration d{12.34 * boost::units::si::mole / boost::units::si::cubic_meter};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t == "12.34 m^-3 mol");   }   //Concentration file I/O, one Concentration   {     const Concentration d{12.34 * boost::units::si::mole / boost::units::si::cubic_meter};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << d;     }     std::ifstream f{filename};     Concentration d_too;     f >> d_too;     if (d != d_too)     {       std::cerr << d << '\n'         << d_too << '\n'       ;     }     assert(d == d_too);   }   //Concentration file I/O, two Concentration   {     const Concentration a{12.34 * boost::units::si::mole / boost::units::si::cubic_meter};     const Concentration b{23.45 * boost::units::si::mole / boost::units::si::cubic_meter};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << a << " " << b;     }     std::ifstream f{filename};     Concentration a_too;     Concentration b_too;     f >> a_too >> b_too;     if (a != a_too)     {       std::cerr << a << '\n'         << a_too << '\n'       ;     }     if (b != b_too)     {       std::cerr << a << '\n'         << b_too << '\n'       ;     }     assert(a == a_too);     assert(b == b_too);   } } #endif` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/concentrationchange.h --------------------------------- - -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef CONCENTRATIONCHANGE_H #define CONCENTRATIONCHANGE_H //Species growth: // The change in species density per time #include "concentration.h" #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include #include #include #pragma GCC diagnostic pop namespace boost {   namespace units {     typedef derived_dimension<       amount_base_dimension,1,       length_base_dimension,-3,       time_base_dimension,-1     >::type concentration_change_dimension;   } // namespace units } // namespace boost namespace boost {   namespace units {     namespace si {       typedef unit concentration_change;       BOOST_UNITS_STATIC_CONSTANT(mole_per_cubic_meter_per_second,concentration_change);       using ConcentrationChange = boost::units::quantity;       std::istream& operator>>(std::istream& is,ConcentrationChange& sd);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     using ConcentrationChange = boost::units::quantity;     #ifndef NDEBUG     void TestConcentrationChange() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // CONCENTRATIONCHANGE_H` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/concentrationchange.cpp ----------------------------------- - -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include "concentrationchange.h" #include #include #include #include #include "fileio.h" #include "testtimer.h" #include "concentration.h" #include "rate.h" std::istream& boost::units::si::operator>>(std::istream& is, ConcentrationChange& sd) {   double value = 0.0;   is >> value;   std::string unit;   is >> unit;   assert(unit == "m^-3");   is >> unit;   assert(unit == "mol");   is >> unit;   assert(unit == "s^-1");   sd = ConcentrationChange(     value     * boost::units::si::mole_per_cubic_meter_per_second);   return is; } #ifndef NDEBUG void ribi::units::TestConcentrationChange() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     ribi::fileio::FileIo();     TestConcentration();     TestRate();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   using ribi::fileio::FileIo;   using ConcentrationChange = boost::units::quantity;   //Concentration density is in species per square meter   {     const ConcentrationChange d{       1.0 * boost::units::si::mole_per_cubic_meter_per_second};     std::stringstream s;     s << d;     const std::string t{s.str()};     //std::cerr << t << std::endl;     assert(t.substr(t.size() - 13,13) == "m^-3 mol s^-1");   }   //Concentration density uses a dot as a seperator   {     const ConcentrationChange d{12.34 * boost::units::si::mole_per_cubic_meter_per_second};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t == "12.34 m^-3 mol s^-1");   }   //Concentration growth can be multiplied by an area to obtain the growth rate   {     using Area = boost::units::quantity;     const ConcentrationChange d{0.1 * boost::units::si::mole_per_cubic_meter_per_second};     const Area a(123.4 * boost::units::si::square_meter);     const auto n = d * a;     std::stringstream s;     s << n;     const std::string t{s.str()};     assert(t.substr(t.size() - 4, 4) == "s^-1");   }   //Concentration density file I/O, one ConcentrationChange   {     const ConcentrationChange d{12.34 * boost::units::si::mole_per_cubic_meter_per_second};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << d;     }     std::ifstream f{filename};     ConcentrationChange d_too;     f >> d_too;     if (d != d_too)     {       std::cerr << d << '\n'         << d_too << '\n'       ;     }     assert(d == d_too);   }   //Concentration density file I/O, two ConcentrationChange   {     const ConcentrationChange a{12.34 * boost::units::si::mole_per_cubic_meter_per_second};     const ConcentrationChange b{23.45 * boost::units::si::mole_per_cubic_meter_per_second};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << a << " " << b;     }     std::ifstream f{filename};     ConcentrationChange a_too;     ConcentrationChange b_too;     f >> a_too >> b_too;     if (a != a_too)     {       std::cerr << a << '\n'         << a_too << '\n'       ;     }     assert(a == a_too);     if (b != b_too)     {       std::cerr << b << '\n'         << b_too << '\n'       ;     }     assert(b == b_too);   }   //Combining ConcentrationDensity, ConcentrationChange and Rate   //Exponential growth   {     const double n_unitless{0.7};     const double r_unitless{1.3};     const Concentration n{n_unitless * boost::units::si::mole_per_cubic_meter};     const Rate r{r_unitless * boost::units::si::per_second};     const ConcentrationChange dndt{n * r};     assert(dndt.value() == n_unitless * r_unitless);   }   //Logistic growth   {     const double n_unitless{0.7};     const double k_unitless{2.0};     const double r_unitless{1.3};     const Concentration n{n_unitless * boost::units::si::mole_per_cubic_meter};     const Concentration k{k_unitless * boost::units::si::mole_per_cubic_meter};     const Rate r{r_unitless * boost::units::si::per_second};     const ConcentrationChange dndt{ n * r * (1.0 - (n / k))};     assert(dndt.value() == n_unitless * r_unitless * (1.0 - (n_unitless / k_unitless)));   }   assert(1==2); } #endif` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/hydrogenmoleculeamount.h ------------------------------------ - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef HYDROGENMOLECULEAMOUNT_H #define HYDROGENMOLECULEAMOUNT_H #include namespace boost {   namespace units {     struct hydrogen_molecule_amount_dimension_tag : base_dimension{};     typedef derived_dimension::type hydrogen_molecule_amount_dimension;   } // namespace units } // namespace boost namespace boost {   namespace units {     namespace si {       typedef unit hydrogen_molecule_amount;       BOOST_UNITS_STATIC_CONSTANT(hydrogen_molecules_mol,hydrogen_molecule_amount);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     #ifndef NDEBUG     void TestHydrogenMoleculeAmount() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // HYDROGENMOLECULEAMOUNT_H` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/hydrogenmoleculeamount.cpp -------------------------------------- - -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef NDEBUG #include "hydrogenmoleculeamount.h" #include #include #include #include "testtimer.h" void ribi::units::TestHydrogenMoleculeAmount() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   using HydrogenMoleculeAmount = boost::units::quantity;   //Hydrogen molecule amounts can be displayed   {     const HydrogenMoleculeAmount sa{1.0 * boost::units::si::hydrogen_molecules_mol};     std::stringstream s;     s << sa;     const std::string t{s.str()};     assert(!t.empty());   }   //#define FIX_ISSUE_999   #ifdef FIX_ISSUE_999   //Hydrogen molecule amounts are in mole   {     const HydrogenMoleculeAmount sa{1.0 * boost::units::si::hydrogen_molecules_mol};     std::stringstream s;     s << sa;     const std::string t{s.str()};     assert(!t.empty());     std::cout << t << std::endl;     assert(t.substr(t.size()-3,3) == "mol");   }   #endif   //Can add hydrogen molecule amounts   {     const double a{1.0};     const double b{2.0};     const double c{a + b};     const HydrogenMoleculeAmount sa{a * boost::units::si::hydrogen_molecules_mol};     const HydrogenMoleculeAmount sb{b * boost::units::si::hydrogen_molecules_mol};     const HydrogenMoleculeAmount sc{sa + sb};     assert(sc == HydrogenMoleculeAmount{c * boost::units::si::hydrogen_molecules_mol});   } } #endif` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/massdensity.h ------------------------- - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef MASSDENSITY_H #define MASSDENSITY_H // Mass per square meter //#include #include /* #include #include namespace boost {   namespace units {     typedef derived_dimension<       mass_base_dimension,1,       length_base_dimension,-2     >::type mass_density_dimension;   } // ~namespace units } // ~namespace boost namespace boost {   namespace units {     namespace si {       using mass_density = unit;       BOOST_UNITS_STATIC_CONSTANT(mass_per_square_meter,mass_density);       BOOST_UNITS_STATIC_CONSTANT(mass_per_square_meters,mass_density);       using MassDensity = boost::units::quantity;       std::istream& operator>>(std::istream& is,SpeciesDensity& sd);     } // ~namespace si   } // ~namespace units } // ~namespace boost */ namespace ribi {   namespace units {     #ifndef NDEBUG     void TestMassDensity() noexcept;     #endif     //using MassDensity = boost::units::quantity;     //std::string ToStr(const SpeciesDensity& density) noexcept;     //SpeciesDensity ToSpeciesDensity(const std::string& s) noexcept;   } //~namespace units } //~namespace ribi #endif // MASSDENSITY_H` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/massdensity.cpp --------------------------- - -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef NDEBUG #include "massdensity.h" #include #include #include #include #include "fileio.h" #include "testtimer.h" #ifdef RIBI_USE_MASS_DENSITY std::istream& boost::units::si::operator>>(std::istream& is, MassDensity& sd) {   double value = 0.0;   is >> value;   std::string unit;   is >> unit;   assert(unit == "m^-2");   sd = MassDensity(value * boost::units::si::mass_per_square_meter);   return is; } #endif void ribi::units::TestMassDensity() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     ribi::fileio::FileIo();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   #ifdef RIBI_USE_MASS_DENSITY   using ribi::fileio::FileIo;   using MassDensity = boost::units::quantity;   //Mass density is in mass per square meter   {     const MassDensity d{1.0 * boost::units::si::mass_per_square_meter};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t.substr(t.size() - 4, 4) == "m^-2");   }   //Mass density uses a dot as a seperator   {     const MassDensity d{12.34 * boost::units::si::mass_per_square_meter};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t == "12.34 m^-2");   }   //Mass density can be multiplied by an area to obtain the number of mass   {     using Area = boost::units::quantity;     const MassDensity d{0.1 * boost::units::si::mass_per_square_meter};     const Area a(123.4 * boost::units::si::square_meter);     const auto n = d * a;     std::stringstream s;     s << n;     const std::string t{s.str()};     assert(t.substr(t.size() - 13, 13) == "dimensionless");   }   //Mass density file I/O   {     const MassDensity d{12.34 * boost::units::si::mass_per_square_meter};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << d;     }     std::ifstream f{filename};     MassDensity d_too;     f >> d_too;     if (d != d_too)     {       std::cerr << d << '\n'         << d_too << '\n'       ;     }     assert(d == d_too);   }   #endif // RIBI_USE_MASS_DENSITY } #endif` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/massflow.h ---------------------- - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef MASSFLOW_H #define MASSFLOW_H #include namespace boost {   namespace units {     typedef derived_dimension<         mass_base_dimension,1,         time_base_dimension,-1       >::type mass_flow_dimension     ;   } // namespace units } // namespace boost namespace boost {   namespace units {     namespace si {       typedef unit mass_flow;       BOOST_UNITS_STATIC_CONSTANT(kilogram_per_second,mass_flow);       BOOST_UNITS_STATIC_CONSTANT(kilogramme_meters_per_second,mass_flow);       BOOST_UNITS_STATIC_CONSTANT(kilograms_metre_per_second,mass_flow);       BOOST_UNITS_STATIC_CONSTANT(kilogrammes_metres_per_second,mass_flow);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     #ifndef NDEBUG     void TestMassFlow() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // MASSFLOW_H` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/massflow.cpp ------------------------ - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef NDEBUG #include "massflow.h" #include #include #include #include "testtimer.h" #include "volumetricflow.h" void ribi::units::TestMassFlow() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   const TestTimer test_timer(__func__,__FILE__,1.0);   //Allow one extra TestTimer, to test MassFlow <-> VolumetricFlow   test_timer.SetMaxCnt(2);   using MassFlow = boost::units::quantity;   using Mass = boost::units::quantity;   using Time = boost::units::quantity;   //MassFlow has unit mass per second, 'kg s^-1'   {     const MassFlow phi_m{         1.0       * boost::units::si::kilogram / boost::units::si::second     };     std::stringstream s;     s << phi_m;     const std::string t{s.str()};     assert(t.substr(t.size() - 7,7) == "kg s^-1");   }   //MassFlow can be obtained by dividing a mass by a time unit   {     const Mass mass{1.0 * boost::units::si::kilogram};     const Time time{1.0 * boost::units::si::second};     const MassFlow phi_m{mass / time};   }   //MassFlow can be converted to VolumetricFlow   {     using Volume = boost::units::quantity;     using VolumetricFlow = boost::units::quantity;     using Density = boost::units::quantity;     const Volume v{1.0 * boost::units::si::cubic_meter};     const Time t{1.0 * boost::units::si::second};     const MassFlow phi_m{       1.0 * boost::units::si::kilogram / boost::units::si::second     };     const Density d{       1.0 * boost::units::si::kilogram / boost::units::si::cubic_meter     };     const VolumetricFlow phi_v{phi_m / d};     //const VolumetricFlow phi_v_wrong{phi_m * d}; //GOOD: does not compile     //const VolumetricFlow phi_v_wrong{d / phi_m}; //GOOD: does not compile   }   test_timer.SetMaxCnt(1); } #endif` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/moleculeamount.h ---------------------------- - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef MOLECULEAMOUNT_H #define MOLECULEAMOUNT_H #include namespace boost {   namespace units {     //1 states that the amount is in moles (of molecules, in this context)     typedef derived_dimension::type molecule_amount_dimension;   } // namespace units } // namespace boost namespace boost {   namespace units {     namespace si {       typedef unit molecule_amount;       BOOST_UNITS_STATIC_CONSTANT(molecules_mol,molecule_amount);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     #ifndef NDEBUG     void TestMoleculeAmount() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // MOLECULEAMOUNT_H` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/moleculeamount.cpp ------------------------------ - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef NDEBUG #include "moleculeamount.h" #include "units.h" #include #include #include #include "moleculeamount.h" #include "testtimer.h" void ribi::units::TestMoleculeAmount() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   const TestTimer test_timer(__func__,__FILE__,1.0);   using MoleculeAmount = boost::units::quantity;   //Can add molecule amounts   {     const MoleculeAmount a{1.0 * boost::units::si::molecules_mol};     const MoleculeAmount b{1.0 * boost::units::si::molecules_mol};     a + b;   }   //Molecule amounts are in mole   {     using MoleculeAmount = boost::units::quantity;     const MoleculeAmount a{1.0 * boost::units::si::molecules_mol};     std::stringstream s;     s << a;     const std::string t{s.str()};     assert(!t.empty());     assert(t.substr(t.size()-3,3) == "mol");   } } #endif` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/rate.h ------------------ - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef RATE_H #define RATE_H //Rate // The relative (unitless) change of something in time #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include #include #include #pragma GCC diagnostic pop namespace boost {   namespace units {     typedef derived_dimension<       time_base_dimension,-1     >::type rate_dimension;   } // namespace units } // namespace boost namespace boost {   namespace units {     namespace si {       typedef unit rate;       BOOST_UNITS_STATIC_CONSTANT(per_second,rate);       using Rate = boost::units::quantity;       std::istream& operator>>(std::istream& is,Rate& sd);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     using Rate = boost::units::quantity;     #ifndef NDEBUG     void TestRate() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // RATE_H` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/rate.cpp -------------------- - -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include "rate.h" #include #include #include #include #include "speciesdensity.h" std::istream& boost::units::si::operator>>(std::istream& is, Rate& sd) {   double value = 0.0;   is >> value;   std::string unit;   is >> unit;   assert(unit == "s^-1");   sd = Rate(     value     * boost::units::si::per_second);   return is; } #ifndef NDEBUG #include "fileio.h" #include "testtimer.h" void ribi::units::TestRate() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     ribi::fileio::FileIo();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   using ribi::fileio::FileIo;   using Rate = boost::units::quantity;   //Species density is in species per square meter   {     const Rate d{       1.0 * boost::units::si::per_second};     std::stringstream s;     s << d;     const std::string t{s.str()};     //std::cerr << t << std::endl;     assert(t.substr(t.size() - 4, 4) == "s^-1");   }   //Species density uses a dot as a seperator   {     const Rate d{12.34 * boost::units::si::per_second};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t == "12.34 s^-1");   }   //Species growth can be multiplied by an area to obtain the growth rate   {     using Area = boost::units::quantity;     const Rate d{0.1 * boost::units::si::per_second};     const Area a(123.4 * boost::units::si::square_meter);     const auto n = d * a;     std::stringstream s;     s << n;     const std::string t{s.str()};     assert(t.substr(t.size() - 4, 4) == "s^-1");   }   //Species density file I/O, one Rate   {     const Rate d{12.34 * boost::units::si::per_second};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << d;     }     std::ifstream f{filename};     Rate d_too;     f >> d_too;     if (d != d_too)     {       std::cerr << d << '\n'         << d_too << '\n'       ;     }     assert(d == d_too);   }   //Species density file I/O, two Rate   {     const Rate a{12.34 * boost::units::si::per_second};     const Rate b{23.45 * boost::units::si::per_second};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << a << " " << b;     }     std::ifstream f{filename};     Rate a_too;     Rate b_too;     f >> a_too >> b_too;     if (a != a_too)     {       std::cerr << a << '\n'         << a_too << '\n'       ;     }     assert(a == a_too);     if (b != b_too)     {       std::cerr << b << '\n'         << b_too << '\n'       ;     }     assert(b == b_too);   } } #endif` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/ribi\_time.h ------------------------ - -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ` #ifndef RIBI_TIME_H #define RIBI_TIME_H //Time // The relative (unitless) change of something in time #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include #include #include #pragma GCC diagnostic pop namespace boost {   namespace units {     namespace si {       using Time = boost::units::quantity;       std::istream& operator>>(std::istream& is,Time& sd);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     using Time = boost::units::quantity;     #ifndef NDEBUG     void TestTime() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // RIBI_TIME_H` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - -  - -  - -  - -  - -  - -./CppUnits/ribi\_time.cpp -------------------------- - -  - - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include "ribi_time.h" #include #include #include #include "fileio.h" std::istream& boost::units::si::operator>>(std::istream& is, Time& sd) {   double value = 0.0;   is >> value;   std::string unit;   is >> unit;   assert(unit == "s");   sd = Time(value * seconds);   return is; } #ifndef NDEBUG #include "testtimer.h" #include void ribi::units::TestTime() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     ribi::fileio::FileIo();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   using ribi::fileio::FileIo;   using Time = boost::units::quantity;   using boost::units::si::seconds;   //Time is in seconds   {     const Time d{1.0 * seconds};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t.substr(t.size() - 1,1) == "s");   }   //Time uses a dot as a seperator   {     const Time d{12.34 * seconds};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t == "12.34 s");   }   //Time file I/O, one Time   {     const Time d{12.34 * seconds};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << d;     }     std::ifstream f{filename};     Time d_too;     f >> d_too;     if (d != d_too)     {       std::cerr << d << '\n'         << d_too << '\n'       ;     }     assert(d == d_too);   }   //Time file I/O, two Time   {     const Time a{12.34 * seconds};     const Time b{23.45 * seconds};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << a << " " << b;     }     std::ifstream f{filename};     Time a_too;     Time b_too;     f >> a_too >> b_too;     if (a != a_too)     {       std::cerr << a << '\n'         << a_too << '\n'       ;     }     assert(a == a_too);     if (b != b_too)     {       std::cerr << b << '\n'         << b_too << '\n'       ;     }     assert(b == b_too);   } } #endif` - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/speciesdensity.h ---------------------------- - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef SPECIESDENSITY_H #define SPECIESDENSITY_H #include #include namespace boost {   namespace units {     using species_density_dimension = derived_dimension::type;   } // ~namespace units } // ~namespace boost namespace boost {   namespace units {     namespace si {       using species_density = unit;       BOOST_UNITS_STATIC_CONSTANT(species_per_square_meter,species_density);       BOOST_UNITS_STATIC_CONSTANT(species_per_square_meters,species_density);       using SpeciesDensity = boost::units::quantity;       std::istream& operator>>(std::istream& is,SpeciesDensity& sd);     } // ~namespace si   } // ~namespace units } // ~namespace boost namespace ribi {   namespace units {     #ifndef NDEBUG     void TestSpeciesDensity() noexcept;     #endif     using SpeciesDensity = boost::units::quantity;   } //~namespace units } //~namespace ribi #endif // SPECIESDENSITY_H` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/speciesdensity.cpp ------------------------------ - -  - - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include "speciesdensity.h" #include #include #include #include "fileio.h" std::istream& boost::units::si::operator>>(std::istream& is, SpeciesDensity& sd) {   double value = 0.0;   is >> value;   std::string unit;   is >> unit;   assert(unit == "m^-2");   sd = SpeciesDensity(value * boost::units::si::species_per_square_meter);   return is; } #ifndef NDEBUG #include "testtimer.h" #include void ribi::units::TestSpeciesDensity() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     ribi::fileio::FileIo();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   using ribi::fileio::FileIo;   using SpeciesDensity = boost::units::quantity;   //Species density is in species per square meter   {     const SpeciesDensity d{1.0 * boost::units::si::species_per_square_meter};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t.substr(t.size() - 4, 4) == "m^-2");   }   //Species density uses a dot as a seperator   {     const SpeciesDensity d{12.34 * boost::units::si::species_per_square_meters};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t == "12.34 m^-2");   }   //Species density can be multiplied by an area to obtain the number of species   {     using Area = boost::units::quantity;     const SpeciesDensity d{0.1 * boost::units::si::species_per_square_meter};     const Area a(123.4 * boost::units::si::square_meter);     const auto n = d * a;     std::stringstream s;     s << n;     const std::string t{s.str()};     assert(t.substr(t.size() - 13, 13) == "dimensionless");   }   //Species density file I/O, one SpeciesDensity   {     const SpeciesDensity d{12.34 * boost::units::si::species_per_square_meter};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << d;     }     std::ifstream f{filename};     SpeciesDensity d_too;     f >> d_too;     if (d != d_too)     {       std::cerr << d << '\n'         << d_too << '\n'       ;     }     assert(d == d_too);   }   //Species density file I/O, two SpeciesDensity   {     const SpeciesDensity a{12.34 * boost::units::si::species_per_square_meter};     const SpeciesDensity b{23.45 * boost::units::si::species_per_square_meter};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << a << " " << b;     }     std::ifstream f{filename};     SpeciesDensity a_too;     SpeciesDensity b_too;     f >> a_too >> b_too;     if (a != a_too)     {       std::cerr << a << '\n'         << a_too << '\n'       ;     }     assert(a == a_too);     if (b != b_too)     {       std::cerr << b << '\n'         << b_too << '\n'       ;     }     assert(b == b_too);   } } #endif` - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/speciesgrowth.h --------------------------- - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef SPECIESGROWTH_H #define SPECIESGROWTH_H //Species growth: // The change in species density per time #include "speciesdensity.h" #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include #include #include #pragma GCC diagnostic pop namespace boost {   namespace units {     typedef derived_dimension<       length_base_dimension,-2,       time_base_dimension,-1     >::type species_growth_dimension;   } // namespace units } // namespace boost namespace boost {   namespace units {     namespace si {       typedef unit species_growth;       BOOST_UNITS_STATIC_CONSTANT(species_per_square_meter_per_second,species_growth);       using SpeciesGrowth = boost::units::quantity;       std::istream& operator>>(std::istream& is,SpeciesGrowth& sd);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     using SpeciesGrowth = boost::units::quantity;     #ifndef NDEBUG     void TestSpeciesGrowth() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // SPECIESGROWTH_H` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/speciesgrowth.cpp ----------------------------- - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #include "speciesgrowth.h" #include #include #include #include "speciesdensity.h" #include "rate.h" std::istream& boost::units::si::operator>>(std::istream& is, SpeciesGrowth& sd) {   double value = 0.0;   is >> value;   std::string unit;   is >> unit;   assert(unit == "m^-2");   is >> unit;   assert(unit == "s^-1");   sd = SpeciesGrowth(     value     * boost::units::si::species_per_square_meter_per_second);   return is; } #ifndef NDEBUG #include #include "fileio.h" #include "testtimer.h" void ribi::units::TestSpeciesGrowth() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     ribi::fileio::FileIo();     TestSpeciesDensity();     TestRate();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   using ribi::fileio::FileIo;   using SpeciesGrowth = boost::units::quantity;   //Species density is in species per square meter   {     const SpeciesGrowth d{       1.0 * boost::units::si::species_per_square_meter_per_second};     std::stringstream s;     s << d;     const std::string t{s.str()};     //std::cerr << t << std::endl;     assert(t.substr(t.size() - 9, 9) == "m^-2 s^-1");   }   //Species density uses a dot as a seperator   {     const SpeciesGrowth d{12.34 * boost::units::si::species_per_square_meter_per_second};     std::stringstream s;     s << d;     const std::string t{s.str()};     assert(t == "12.34 m^-2 s^-1");   }   //Species growth can be multiplied by an area to obtain the growth rate   {     using Area = boost::units::quantity;     const SpeciesGrowth d{0.1 * boost::units::si::species_per_square_meter_per_second};     const Area a(123.4 * boost::units::si::square_meter);     const auto n = d * a;     std::stringstream s;     s << n;     const std::string t{s.str()};     assert(t.substr(t.size() - 4, 4) == "s^-1");   }   //Species density file I/O, one SpeciesGrowth   {     const SpeciesGrowth d{12.34 * boost::units::si::species_per_square_meter_per_second};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << d;     }     std::ifstream f{filename};     SpeciesGrowth d_too;     f >> d_too;     if (d != d_too)     {       std::cerr << d << '\n'         << d_too << '\n'       ;     }     assert(d == d_too);   }   //Species density file I/O, two SpeciesGrowth   {     const SpeciesGrowth a{12.34 * boost::units::si::species_per_square_meter_per_second};     const SpeciesGrowth b{23.45 * boost::units::si::species_per_square_meter_per_second};     const std::string filename{FileIo().GetTempFileName(".txt")};     {       std::ofstream f{filename};       f << a << " " << b;     }     std::ifstream f{filename};     SpeciesGrowth a_too;     SpeciesGrowth b_too;     f >> a_too >> b_too;     if (a != a_too)     {       std::cerr << a << '\n'         << a_too << '\n'       ;     }     assert(a == a_too);     if (b != b_too)     {       std::cerr << b << '\n'         << b_too << '\n'       ;     }     assert(b == b_too);   }   //Combining SpeciesDensity, SpeciesGrowth and Rate   //Exponential growth   {     const double n_unitless{0.7};     const double r_unitless{1.3};     const SpeciesDensity n{n_unitless * boost::units::si::species_per_square_meter};     const Rate r{r_unitless * boost::units::si::per_second};     const SpeciesGrowth dndt{n * r};     assert(dndt.value() == n_unitless * r_unitless);   }   //Logistic growth   {     const double n_unitless{0.7};     const double k_unitless{2.0};     const double r_unitless{1.3};     const SpeciesDensity n{n_unitless * boost::units::si::species_per_square_meter};     const SpeciesDensity k{k_unitless * boost::units::si::species_per_square_meter};     const Rate r{r_unitless * boost::units::si::per_second};     const SpeciesGrowth dndt{ n * r * (1.0 - (n / k))};     assert(dndt.value() == n_unitless * r_unitless * (1.0 - (n_unitless / k_unitless)));   } } #endif` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/sulfidemoleculeamount.h ----------------------------------- - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef SULFIDEMOLECULEAMOUNT_H #define SULFIDEMOLECULEAMOUNT_H #include namespace boost {   namespace units {     struct sulfide_molecule_amount_dimension_tag : base_dimension{};     typedef derived_dimension::type sulfide_molecule_amount_dimension;   } // namespace units } // namespace boost namespace boost {   namespace units {     namespace si {       typedef unit sulfide_molecule_amount;       BOOST_UNITS_STATIC_CONSTANT(sulfide_molecules_mol,sulfide_molecule_amount);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     #ifndef NDEBUG     void TestSulfideMoleculeAmount() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // SULFIDEMOLECULEAMOUNT_H` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/sulfidemoleculeamount.cpp ------------------------------------- - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef NDEBUG #include "sulfidemoleculeamount.h" #include #include #include #include "testtimer.h" void ribi::units::TestSulfideMoleculeAmount() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     //ribi::fileio::FileIo();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   using SulfideMoleculeAmount = boost::units::quantity;   //Sulfide molecule amounts can be displayed   {     const SulfideMoleculeAmount sa{1.0 * boost::units::si::sulfide_molecules_mol};     std::stringstream s;     s << sa;     const std::string t{s.str()};     assert(!t.empty());   }   //#define FIX_ISSUE_999   #ifdef FIX_ISSUE_999   //Sulfide molecule amounts are in mole   {     const SulfideMoleculeAmount sa{1.0 * boost::units::si::sulfide_molecules_mol};     std::stringstream s;     s << sa;     const std::string t{s.str()};     assert(!t.empty());     std::cout << t << std::endl;     assert(t.substr(t.size()-3,3) == "mol");   }   #endif   //Can add sulfide molecule amounts   {     const double a{1.0};     const double b{2.0};     const double c{a + b};     const SulfideMoleculeAmount sa{a * boost::units::si::sulfide_molecules_mol};     const SulfideMoleculeAmount sb{b * boost::units::si::sulfide_molecules_mol};     const SulfideMoleculeAmount sc{sa + sb};     assert(sc == SulfideMoleculeAmount{c * boost::units::si::sulfide_molecules_mol});   } } #endif` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/units.h ------------------- - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef RIBI_UNITS_H #define RIBI_UNITS_H ///Collection of my own units namespace ribi {   namespace units {     #ifndef NDEBUG     void Test() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // RIBI_UNITS_H` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/units.cpp --------------------- - -  - - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef NDEBUG #include "units.h" #include #include #include #include "concentration.h" #include "hydrogenmoleculeamount.h" #include "rate.h" #include "massflow.h" #include "moleculeamount.h" #include "speciesdensity.h" #include "speciesgrowth.h" #include "sulfidemoleculeamount.h" #include "testtimer.h" #include "ribi_time.h" #include "volumetricflow.h" void ribi::units::Test() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   {     TestConcentration();     TestHydrogenMoleculeAmount();     TestMassFlow();     TestRate();     TestMoleculeAmount();     TestSpeciesDensity();     TestSpeciesGrowth();     TestSulfideMoleculeAmount();     TestTime();     TestVolumetricFlow();   }   const TestTimer test_timer(__func__,__FILE__,1.0);   #ifdef MUST_NOT_COMPILE_CREATE_HYDROGEN_FROM_SULFIDE   //Cannot create hydrogen from sulfide   {     using HydrogenMoleculeAmount = boost::units::quantity;     const HydrogenMoleculeAmount h{1.0 * boost::units::si::sulfide_molecules_mol}; //Must fail   }   #endif   #ifdef MUST_NOT_COMPILE_CREATE_SULFIDE_FROM_HYDROGEN   //Cannot create sulfide from hydrogen   {     using SulfideMoleculeAmount = boost::units::quantity;     const SulfideMoleculeAmount s{1.0 * boost::units::si::hydrogen_molecules_mol};   }   #endif   #ifdef MUST_NOT_COMPILE_ADD_HYDROGEN_AND_SULFIDE   //Cannot add hydrogen and sulfide molecule amounts   {     using HydrogenMoleculeAmount = boost::units::quantity;     using SulfideMoleculeAmount = boost::units::quantity;     const HydrogenMoleculeAmount h{1.0 * boost::units::si::hydrogen_molecules_mol};     const SulfideMoleculeAmount s{1.0 * boost::units::si::sulfide_molecules_mol};     h + s; //Must fail   }   #endif } #endif` - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -./CppUnits/volumetricflow.h ---------------------------- - -  - - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ` #ifndef VOLUMETRICFLOW_H #define VOLUMETRICFLOW_H #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include #include #include #pragma GCC diagnostic pop namespace boost {   namespace units {     typedef derived_dimension<       length_base_dimension,3,       time_base_dimension,-1     >::type volumetric_flow_dimension;   } // namespace units } // namespace boost namespace boost {   namespace units {     namespace si {       typedef unit volumetric_flow;       BOOST_UNITS_STATIC_CONSTANT(cubic_meter_per_second,volumetric_flow);       BOOST_UNITS_STATIC_CONSTANT(cubic_meters_per_second,volumetric_flow);       BOOST_UNITS_STATIC_CONSTANT(cubic_metre_per_second,volumetric_flow);       BOOST_UNITS_STATIC_CONSTANT(cubic_metres_per_second,volumetric_flow);     } // namespace si   } // namespace units } //namespace boost namespace ribi {   namespace units {     #ifndef NDEBUG     void TestVolumetricFlow() noexcept;     #endif   } //~namespace units } //~namespace ribi #endif // VOLUMETRICFLOW_H` - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - -  - -  - -  - -  - -  - -./CppUnits/volumetricflow.cpp ------------------------------ - -  - - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ` #ifndef NDEBUG #include "volumetricflow.h" #include #include #include "massflow.h" #include "testtimer.h" void ribi::units::TestVolumetricFlow() noexcept {   {     static bool is_tested{false};     if (is_tested) return;     is_tested = true;   }   const TestTimer test_timer(__func__,__FILE__,1.0);   //Allow one extra TestTimer, to test MassFlow <-> VolumetricFlow   test_timer.SetMaxCnt(2);   using VolumetricFlow = boost::units::quantity;   using Volume = boost::units::quantity;   using Time = boost::units::quantity;   //VolumetricFlow has unit cubic metre per second, 'm^3 s^-1'   {     const VolumetricFlow phi_v{         1.0       * boost::units::si::cubic_meter / boost::units::si::second     };     std::stringstream s;     s << phi_v;     const std::string t{s.str()};     assert(t.substr(t.size() - 8,8) == "m^3 s^-1");   }   //VolumetricFlow can be obtained by dividing a volume by a time unit   {     const Volume volume{1.0 * boost::units::si::cubic_meter};     const Time time{1.0 * boost::units::si::second};     const VolumetricFlow phi_v{volume / time};   }   //VolumetricFlow can be converted to MassFlow   {     using Volume = boost::units::quantity;     using MassFlow = boost::units::quantity;     using Density = boost::units::quantity;     const Volume v{1.0 * boost::units::si::cubic_meter};     const Time t{1.0 * boost::units::si::second};     const VolumetricFlow phi_v{v / t};     const Density d{       1.0        * boost::units::si::kilogram / boost::units::si::cubic_meter     };     const MassFlow phi_m{phi_v * d};   }   test_timer.SetMaxCnt(1); } #endif` - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -  - -  - -  - -  - -  - -  - +Moved to [https://github.com/richelbilderbeek/RibiClasses/tree/master/CppUnits](https://github.com/richelbilderbeek/RibiClasses/tree/master/CppUnits). \ No newline at end of file diff --git a/content/CppUnsigned.md b/content/CppUnsigned.md index 8c4aa2b0..ea4415b3 100644 --- a/content/CppUnsigned.md +++ b/content/CppUnsigned.md @@ -1,48 +1,11 @@ - -  - -  - -  - -  - -  - -([C++](Cpp.md)) [unsigned](CppUnsigned.md) -============================================ - -  +# ([C++](Cpp.md)) [unsigned](CppUnsigned.md) [unsigned](CppUnsigned.md) is a [keyword](CppKeyword.md) that modifies a [data type](CppDataType.md) to hold only positive values. -  - -  - -  +## [Examples](CppExample.md) -  - -  - -[Examples](CppExample.md) --------------------------- - -  - -- [unsigned example 1: one minus two](CppUnsignedExample1.md) - -  - -  - -  - -  - -  + * [unsigned example 1: one minus two](CppUnsignedExample1.md) [Advice](CppAdvice.md) ----------------------- @@ -105,13 +68,13 @@ a [data type](CppDataType.md) to hold only positive values. 'Advice', item 19: 'View signed to unsigned and unsigned to signed conversions with suspicion' 6. [C++ FAQ - Lite](http://www.parashift.com/c++-faq/numeric-literal-suffixes.html). + Lite](https://isocpp.org/wiki/faq/newbie#numeric-literal-suffixes). \[29.12\] What's the point of the L, U and f suffixes on numeric literals?: 'It's probably a good idea to use unsigned integers for variables that are always >= 0. \[...\] at least if you are careful to check your ranges' 7. [C++ FAQ - Lite](http://www.parashift.com/c++-faq/numeric-literal-suffixes.html). + Lite](https://isocpp.org/wiki/faq/newbie#numeric-literal-suffixes). \[29.12\] What's the point of the L, U and f suffixes on numeric literals?: 'If you end up using unsigned variables, it is generally a good idea to force your numeric literals to also be unsigned'