Login  Register

Re: c++0x

Posted by Luigi Ballabio on Jun 13, 2013; 9:57am
URL: http://quantlib.414.s1.nabble.com/c-0x-tp14280p14363.html

Hi Peter,
    as for the errors: are they still there with the current master
(that is, what used to be trunk in svn)? a couple of weeks ago I've
added to the methods an explicit conversion to bool that should have
fixed the issue.

I would delay introducing C++11 features for the time being (and leave
it to you to add -Wno-deprecated to your flags...)

Later,
    Luigi


On Sat, May 25, 2013 at 8:13 PM, Peter Caspers <[hidden email]> wrote:

> Hi Luigi, all,
>
> we discussed compiling the core lib under the c++11 standard (e.g. with
> g++ -std=c++0x). This produces some errors which can be fixed easily
> (keeping backward compatibility):
>
> https://github.com/pcaspers/quantlib/commit/5b32b7705530264551e0622d0a2673813067be5b
>
> What is left is a bunch of warnings saying that std::auto_ptr is
> depricated under c++11, the replacement being std::unique_ptr. A
> possible solution is to replace the auto_ptr in the source by unique_ptr
> (thus upgrading the code to c++11 already) and replace the unique_ptr by
> auto_ptr again in case that compilation is done under c++ versions <
> 11. I have done this here
>
> https://github.com/pcaspers/quantlib/commit/3e47a82a936112f12e3bb502292833d860f5aac9
>
> with a #define in qldefines.hpp resetting the pointers to auto_ptr again
> based on the boost macro BOOST_NO_CXX_SMART_PTR. Unfortunately this
> macro is available only in later boost versions so if one uses an older
> one and provides no c++11 support he or she will get errors. Therefore
> the following solution might be better
>
> https://github.com/pcaspers/quantlib/commit/6db965375b02094a7ea0da4e48efd7e0a1b8fd85
>
> using the __cplusplus macro to identify c++11. However since gcc sets
> this macro simply to 1 in versions 4.6 (should be solved starting in
> 4.7), I had to add another criterion for gcc based on
> __GXX_EXPERIMENTAL_CXX0X_.
>
> For msvc 2010 the __cplusplus is also not 201103L but still 199711L. This
> seems also to be the case in 2012 and this specific case was reported as a bug to
> Microsoft,
>
> http://connect.microsoft.com/VisualStudio/feedback/details/763051/a-value-of-predefined-macro-cplusplus-is-still-199711l
>
> though not solved yet. Therefore I added a direct test on msvc 2010 or
> higher versions based on _MSC_VER
>
> https://github.com/pcaspers/quantlib/commit/796beb89e2a707f951b77869bf869694e67ac769
>
> This final solution should work for all versions of msvc and gcc. I can not check other
> compilers however.
>
> Since the #define seems a bit like a dirty hack we also thought of a
> typedef. But then we would need a template typedef which is available only in
> c++11 again and a metaprogramming-like workaround a la
>
> template<class T> struct PTR {
>     typedef std::unique_ptr<T> Type;
> };
>
> PTR<double>::Type a(new double(0.0));
>
> does not seem to improve the code either.
>
> Do you think we should do the upgrade to c++11 like propsed above or is there
> maybe a better solution (I bet there is...). Or should we defer the
> upgrade until a later release ? I personally would very much like to be
> able to compile under c++11 without warnings already now.
>
> Thank you
>  Peter
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev