Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
f02e4100
Commit
f02e4100
authored
Nov 07, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Undo highlight since it's not working and simplify markup
parent
e41ca7b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
README.rst
README.rst
+9
-9
No files found.
README.rst
View file @
f02e4100
.. highlight: c++
C++ Format
==========
...
...
@@ -56,21 +54,23 @@ See the `documentation <http://cppformat.readthedocs.org/en/latest/>`_ for more
Examples
--------
This prints ``Hello, world!`` to stdout::
This prints ``Hello, world!`` to stdout:
.. code:: c++
fmt::print("Hello, {}!", "world"); // uses Python-like format string syntax
fmt::printf("Hello, %s!", "world"); // uses printf format string syntax
Arguments can be accessed by position and arguments' indices can be repeated:
.. code
-block
:: c++
.. code:: c++
std::string s = fmt::format("{0}{1}{0}", "abra", "cad");
// s == "abracadabra"
C++ Format can be used as a safe portable replacement for ``itoa``:
.. code
-block
:: c++
.. code:: c++
fmt::MemoryWriter w;
w << 42; // replaces itoa(42, buffer, 10)
...
...
@@ -80,7 +80,7 @@ C++ Format can be used as a safe portable replacement for ``itoa``:
An object of any user-defined type for which there is an overloaded
:code:`std::ostream` insertion operator (``operator<<``) can be formatted:
.. code
-block
:: c++
.. code:: c++
class Date {
int year_, month_, day_;
...
...
@@ -102,7 +102,7 @@ macro to create your own functions similar to `format
`print <http://cppformat.readthedocs.org/en/latest#fmt::print__StringRef.ArgListCR>`_
which take arbitrary arguments:
.. code
-block
:: c++
.. code:: c++
// Prints formatted error message.
void report_error(const char *format, fmt::ArgList args) {
...
...
@@ -166,13 +166,13 @@ IOStreams
The main issue with IOStreams is best illustrated with an example:
.. code
-block
:: c++
.. code:: c++
std::cout << std::setprecision(2) << std::fixed << 1.23456 << "\n";
which is a lot of typing compared to printf:
.. code
-block
:: c++
.. code:: c++
printf("%.2f\n", 1.23456);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment