Giter Club home page Giter Club logo

p1160's Introduction

Purpose

Code in this repository is for demonstration purposes only. It is not meant to be used as-is in for any other purpose than being able to follow the WG21 ISO C++ Standard Library proposal paper P1160, or its accompanying presentations available on YouTube.

Since this code places the proposed names into the std::pmr namespace while it is not part of the "implementation" (what ships with the compiler) it, technically, is undefined behavior.

The code and the simple "build system" worked with compilers and standard libraries at the time of the proposal, but it is not maintained as the proposal could not go forward.

The code itself was a first introduction into the idea, not what a modern, or postmodern C++ library component should look like. The paper discusses this, and notes that the "API" should be rethinked in light of all the new core language and library features.

P1160 Add Test Polymorphic Memory Resource To The Standard Library

This repository contains the source code and build system for an example implementation of a std::pmr compatible polymorphic memory resource, intended for use in instrumented tests. The paper which describes the motivation, operation, and other aspects of this code can be found in the WG21 paper repository.

Prerequisites

  • CMake
  • MSVC 2017 or gcc-9

At the time of writing the Microsoft Visual Studio 2017 and gcc-9 (trunk) are the only compilers that implement std::pmr as specified in the C++17 specification, so those are the only to toolchains that have been tested (it's likely to compatible with more recent versions of those compilers)

The most relevant instructions for installing gcc (at the time of writing, 2019.Apr.20): See https://gcc.gnu.org/wiki/InstallingGCC and replace gcc-4.6.0.tar.gz with a snapshot such as https://gcc.gnu.org/pub/gcc/snapshots/LATEST-9/

libc++ (i.e. the native library for clang) does not yet have a standard pmr implementation. I was able to compile the code in this repository using <experimental/memory_resource> that libc++ implements currently (May 2019).

Recorded Presentations

C++ Now 2019, Aspen, CO

C++ Now 2019, Aspen, CO

How to Understand the Code

The repository consists of 5 major parts:

  • supportlib -- macros and printing helpers (static lib)
  • stdpmr -- the implementations of the proposed types and the exception testing algorithm (static lib)
  • pstring -- a series of examples of testing and fixing an imaginary (and quite pathological) string class (executables)
  • exception_testing -- an example using the exception_test_loop
  • patchpmr -- hacks to make clang with libc++ and older GNU libraries with experimental support work

Please read the paper, or watch the presentation, to better understand the repository contents.

Versions of this Repository

Please use the master branch of this repository unless you are following a presentation from a conference, or for a specific paper revision, in which case I suggest checking out the corresponding tag.

Versioning

Git tag: R0 -- Corresponds to the paper revision P1160R0

Git tag: CppNow2019 -- added gcc support, reorganized the code, switched to cmake

Git tag: CppCon2019 -- fixed handling of 0 sized allocations to the standard way (allocating and not returning 0)

Troubleshooting

If you find any issue or have any concerns please do not hesitate to open an issue.

Pull requests are welcome, however since this code accompanies a paper, changes that would change the essence of the proposal would be better be addressed during WG21 discussions.

p1160's People

Contributors

cppguru avatar kpfleming avatar phalpern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

p1160's Issues

Missing [[maybe_unused]]

test_resource.cpp:297 is missing a [[maybe_unused]] on the alignment parameter due to the alignment check being commented out. Having to report via mobile so cannot do pull_request easily, sorry.

How to query out of bounds checks etc in tests?

I have probably missed something, but there seems to be a logical inconsistency in the test_resource. I want to query eg the bounds_errors() function in a gtest showing case2. But whilst the test_resource is valid those counters show zero, they're seemingly only set in the destructor, after which they are not reachable.

I guess what I'm asking is if it makes sense to expose a perform_checks() member function to trigger things?

Do not add to std::pmr

Since this isn't in the standard, and the proposal to add it was rejected, it should not be in std::pmr.

The response from the committee was that it's useful as a third-party library but isn't needed in the standard. But this third-party library has undefined behaviour due to adding things to namespace std. It would be more useful as a third-party library if it didn't have undefined behaviour.

the kind of output stream should be configurable

the user should have a possibility to select the kind of output stream (stdout, stderr, file, etc. ) either per test_resource instance or for all test_resource instances (optional, globally).
the default output stream of test_resource should be stdout.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.