How to SetBasePath in ConfigurationBuilder in Core 2.0

How can I set the base path in ConfigurationBuilder in Core 2.0. I have googled and found this question, this from Microsoft docs, and the 2.0 docs online but they seem to be using a version of Microsoft.Extension.Configuration from 1.0.0-beta8. I want to read appsettings.json. Is there a new way of doing this in Core … Read more

Internal typedefs in C++ – good style or bad style?

Something I have found myself doing often lately is declaring typedefs relevant to a particular class inside that class, i.e. class Lorem { typedef boost::shared_ptr<Lorem> ptr; typedef std::vector<Lorem::ptr> vector; // // … // }; These types are then used elsewhere in the code: Lorem::vector lorems; Lorem::ptr lorem( new Lorem() ); lorems.push_back( lorem ); Reasons I … Read more

Why can lambdas be better optimized by the compiler than plain functions?

In his book The C++ Standard Library (Second Edition) Nicolai Josuttis states that lambdas can be better optimized by the compiler than plain functions. In addition, C++ compilers optimize lambdas better than they do ordinary functions. (Page 213) Why is that? I thought when it comes to inlining there shouldn’t be any difference any more. … Read more

What are some uses of decltype(auto)?

In c++14 the decltype(auto) idiom is introduced. Typically its use is to allow auto declarations to use the decltype rules on the given expression. Searching for examples of “good” usage of the idiom I can only think of things like the following (by Scott Meyers), namely for a function’s return type deduction: template<typename ContainerType, typename … Read more