Comments (3)
Hi,
this seems possible to me. A way to implement this would be to upgrade the part of the algorithm to be able to look at the next two types instead of only one, and pop them both off if there is a size_t
and a char*
coming.
For implementation mechanics, this means that at this code line we could feed the list of the remaining types to the format_str
function, so it can consume as many as it wants. Then, it could return the rest of the list. Looking at this, my gut feel says that we would not need to change much around that.
I would however certainly not implement this like in your example where writing {}
suffices, because i think it is too dangerous to have just the order of a size_t
and a char*
types in the arguments and then imply "so this must be a string view".
In that scenario i would at least have some kind of {sv}
so the user can express "yes the following size_t and char* values are really from a string view and you can use them like that", similar as we already do that for string pointers where the user has to write {s}
.
What do you think?
from pprintpp.
I was hoping there would be a way to not have to provide the size and data pointer directly, rather just the string view itself
have this library add the argument, but I guess that's not possible? The {sv} option would definitely be useful.
from pprintpp.
Oh right, i missed that detail of your example.
It is possible, but then we'd be creating custom code again (Just like the template-based printf function in Bjarne's original C++ book).
The point of pprintpp is that it only creates the format string and leaves the rest of the printf call as is, resulting in zero extra code per printf call.
It seems like libfmt is what you need.
from pprintpp.
Related Issues (15)
- reorder printf paramters HOT 1
- How to integrate with user defined types HOT 12
- C++11 Lambda expression instead of local class/struct in AUTOFORMAT HOT 2
- Thank you! HOT 2
- Does {s} work with std::string_view? HOT 1
- pprintpp needs extra cstdio include
- Mixing format syles causes wrong output HOT 1
- Explicit hexadecimal format with signed argument HOT 1
- Explicit length identifier broken HOT 2
- AVOID_STL requires STL includes HOT 1
- Grouping HOT 3
- Header soup HOT 3
- tie_types ... no implementation ? HOT 1
- https://github.com/dbj-systems/pprintpp_msvc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pprintpp.