from Microsoft STL, but multi-platform

Overview

mscharconv

<charconv> from Microsoft STL, but multi-platform.

Tested with MSVC, gcc, and clang on Windows, Linux, and macOS (will likely work on other platforms supported by any of these compilers)

Usage

The library is header only. You can clone the repo or copy the contents of the include directory in your project.

Alternatively you can use with CMake. The provided CMakeLists.txt defines an INTERFACE target mscharconv.

To use the library in your code simply include <msstl/charconv.hpp> and use to_chars and from_chars from the namespace msstl.

C++17 or later is needed.

Example

#include <msstl/charconv.hpp>
#include <iostream>
#include <string_view>

int main() {
    std::string_view pi_str = "3.14159 is pi";
    double pi;
    auto [p, ec] = msstl::from_chars(pi_str.data(), pi_str.data() + pi_str.length(), pi);
    if (ec != std::errc{}) {
        std::cerr << "Error converting \"" << pi_str << "\" to double\n";
        return 1;
    }
    std::cout << "Got double " << pi << ". The rest is \"" << p << "\".\n";

    return 0;
}

Additional Utilities

An additional header util.hpp is provided with the library with non-standard util functions in namespace msstl::util. Note that util.hpp is NOT self contained. You must include it after including charconv.hpp.

The utility functions are:

  • bool from_string(std::string_view str, INTEGER& out, int base = 10); - convert string to integral number with a given base. Will return true if the conversion is successful. The string must be an integer and nothing more. Even though from_chars supports inputs like "123 and some text" and will stop at the first non-integer character, from_string will consider this to be an invalid input and return false.
  • bool from_string(std::string_view str, FLOATING_POINT_NUM& out); - convert a string to a floating point number. Return true is successful. Same restrictions as above apply.

Advanced usage

For the basic usage of the library one needs to include charconv.hpp which is quite big. It contains a lot of code and huge helper arrays. If you include charconv in many places of your code, it may lead to long compilation times. The advanced usage of the library allows the functions to be compiled separately and only once per project. To enable this, instead of including charconv.hpp include charconv_fwd.hpp and in a single place of your code define MSCHARCONV_IMPLEMENT and then include charconv.hpp.

Additionally if you want to provide a shared library interface to the functions, define MSCHARCONV_API to your import/export symbols, before including charconv_fwd.hpp

Development

The library is created by automatically converting headers from a clone of Microsoft STL with the Ruby script convert-msstl-files.rb. Additionally support functions and macros are provided in charconv_impl.inl.

License

Copyright (c) Microsoft Corporation, Borislav Stanimirov, and contributors.

SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

Issues
  • Usage of ulong32

    Usage of ulong32

    Hello!

    Recommend changing ulong32 to use cstdint's uint32_t. uint32_t is needed be some of the builtin's used and gets flagged as a conversion error on latest clang. I've also added some static_casts in order to allow compilation under werror.

    msstl.zip

    opened by seppeon 5
Owner
Borislav Stanimirov
A (mostly) C++ programmer
Borislav Stanimirov
Low dependency(C++11 STL only), good portability, header-only, deep neural networks for embedded

LKYDeepNN LKYDeepNN 可訓練的深度類神經網路 (Deep Neural Network) 函式庫。 輕量,核心部份只依賴 C++11 標準函式庫,低相依性、好移植,方便在嵌入式系統上使用。 Class diagram 附有訓練視覺化 demo 程式 訓練視覺化程式以 OpenCV

Lin Kao-Yuan 39 Apr 27, 2022
Microsoft Cognitive Toolkit (CNTK), an open source deep-learning toolkit

CNTK Chat Windows build status Linux build status The Microsoft Cognitive Toolkit (https://cntk.ai) is a unified deep learning toolkit that describes

Microsoft 17.2k Jun 24, 2022
EdgeKiller is a simple application that fully replaces Microsoft Edge with the Browser of choice.

EdgeKiller EdgeKiller is a simple application that fully replaces Microsoft Edge with the Browser of choice, while also intercepting all the microsoft

Jan Ochwat 2 Nov 30, 2021
Microsoft Cognitive Toolkit (CNTK), an open source deep-learning toolkit

The Microsoft Cognitive Toolkit is a unified deep learning toolkit that describes neural networks as a series of computational steps via a directed graph.

Microsoft 17.2k Jun 26, 2022
A custom GEGL filter that does layer effects. It may not be non-destructive but you can make presets of your favorite text styles

A custom GEGL filter that does layer effects. It may not be non-destructive but you can make presets of your favorite text styles. Futures plans are going to include an image file overlay, and pro tip you can do a multistroke if sacrifice a shadow/glow.

null 4 Jun 21, 2022
OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation

Build Type Linux MacOS Windows Build Status OpenPose has represented the first real-time multi-person system to jointly detect human body, hand, facia

null 24.5k Jul 2, 2022
SecMML: Secure MPC(multi-party computation) Machine Learning Framework

SecMML 介绍 SecMML是FudanMPL(Multi-Party Computation + Machine Learning)的一个分支,是用于训练机器学习模型的高效可扩展的安全多方计算(MPC)框架,基于BGW协议实现。此框架可以应用到三个及以上参与方联合训练的场景中。目前,SecMM

null 74 Jun 27, 2022
YOLOv4 accelerated wtih TensorRT and multi-stream input using Deepstream

Deepstream 5.1 YOLOv4 App This Deepstream application showcases YOLOv4 running at high FPS throughput! P.S - Click the gif to watch the entire video!

Akash James 31 Apr 21, 2022
A multi object tracking Library Based on tensorrt

YoloV5_JDE_TensorRT_for_Track Introduction A multi object detect and track Library Based on tensorrt 一个基于TensorRT的多目标检测和跟踪融合算法库,可以同时支持行人的多目标检测和跟踪,当然也可

zwg_cv 46 Jun 23, 2022
ORB-SLAM3 is the first real-time SLAM library able to perform Visual, Visual-Inertial and Multi-Map SLAM with monocular, stereo and RGB-D cameras, using pin-hole and fisheye lens models.

Just to test for my research, and I add coordinate transformation to evaluate the ORB_SLAM3. Only applied in research, and respect the authors' all work.

B.X.W 4 May 13, 2022
Linux multi-touch gesture recognizer

Follow Touchégg on... Touchégg Touchégg is an app that runs in the background and transform the gestures you make on your touchpad or touchscreen into

José Expósito 2.6k Jun 27, 2022
Port of the 2020 support library to Raspberry Pi for the VL53L3CX Time-of-Flight ranging sensor with advanced multi-object detection

Port of ST VL53L3CX (2020) driver library to Raspberry Pi This is a port of the support library to Raspberry Pi for the VL53L3CX Time-of-Flight rangin

Niall Douglas 3 May 18, 2022
SIMULATeQCD is a multi-GPU Lattice QCD framework that makes it simple and easy for physicists to implement lattice QCD formulas while still providing the best possible performance.

SIMULATeQCD a SImple MUlti-GPU LATtice code for QCD calculations SIMULATeQCD is a multi-GPU Lattice QCD framework that makes it simple and easy for ph

null 10 Apr 23, 2022
Multi-tap FDN reverb

Eko Multi-tap Diffusion Network reverb Modelled on the Rounds Reverb by native istruments with some additional features not found on the orginal. Eko

null 7 Apr 6, 2022
A program developed using MPI for distributed computation of Histogram for large data and their performance anaysis on multi-core systems

mpi-histo A program developed using MPI for distributed computation of Histogram for large data and their performance anaysis on multi-core systems. T

Raj Shrestha 2 Dec 21, 2021
Tandem - [CoRL 21'] TANDEM: Tracking and Dense Mapping in Real-time using Deep Multi-view Stereo

TANDEM: Tracking and Dense Mapping in Real-time using Deep Multi-view Stereo Lukas Koestler1*    Nan Yang1,2*,†    Niclas Zeller2,3    Daniel Cremers1

TUM Computer Vision Group 624 Jun 23, 2022
Multi-Scale Representation Learning on Proteins

Multi-Scale Representation Learning on Proteins (Under Construction and Subject to Change) Pending: Update links for dataset. This is the official PyT

Vignesh Ram Somnath 15 Jun 23, 2022
Distributed machine learning platform

Veles Distributed platform for rapid Deep learning application development Consists of: Platform - https://github.com/Samsung/veles Znicz Plugin - Neu

Samsung 897 May 28, 2022
Hopsworks - Data-Intensive AI platform with a Feature Store

Give us a star if you appreciate what we do What is Hopsworks? Quick Start Development and Operational ML on Hopsworks Docs Who’s behind Hopsworks? Op

Logical Clocks AB 720 Jun 19, 2022