Undo highlight since it's not working and simplify markup

This commit is contained in:
Victor Zverovich
2014-11-07 07:04:03 -08:00
parent e41ca7b951
commit f02e4100db

View File

@ -1,5 +1,3 @@
.. highlight: c++
C++ Format C++ Format
========== ==========
@ -56,21 +54,23 @@ See the `documentation <http://cppformat.readthedocs.org/en/latest/>`_ for more
Examples 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::print("Hello, {}!", "world"); // uses Python-like format string syntax
fmt::printf("Hello, %s!", "world"); // uses printf 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: 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"); std::string s = fmt::format("{0}{1}{0}", "abra", "cad");
// s == "abracadabra" // s == "abracadabra"
C++ Format can be used as a safe portable replacement for ``itoa``: C++ Format can be used as a safe portable replacement for ``itoa``:
.. code-block:: c++ .. code:: c++
fmt::MemoryWriter w; fmt::MemoryWriter w;
w << 42; // replaces itoa(42, buffer, 10) 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 An object of any user-defined type for which there is an overloaded
:code:`std::ostream` insertion operator (``operator<<``) can be formatted: :code:`std::ostream` insertion operator (``operator<<``) can be formatted:
.. code-block:: c++ .. code:: c++
class Date { class Date {
int year_, month_, day_; 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>`_ `print <http://cppformat.readthedocs.org/en/latest#fmt::print__StringRef.ArgListCR>`_
which take arbitrary arguments: which take arbitrary arguments:
.. code-block:: c++ .. code:: c++
// Prints formatted error message. // Prints formatted error message.
void report_error(const char *format, fmt::ArgList args) { 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: 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"; std::cout << std::setprecision(2) << std::fixed << 1.23456 << "\n";
which is a lot of typing compared to printf: which is a lot of typing compared to printf:
.. code-block:: c++ .. code:: c++
printf("%.2f\n", 1.23456); printf("%.2f\n", 1.23456);