Generating a table with vertical text, like I did with the sad history of the C++ throw(…) exception specifier

Raymond Chen

Raymond

In The sad history of the C++ throw(...) exception specifier, I presented some tables with vertical text. Here’s how I did it. (I simplified the table a bit to allow me to focus on the part that does the vertical text.)

<TABLE BORDER=1 STYLE="border-collapse: collapse">
<TR>
    <TH COLSPAN=2>Specifier</TH>
    <TH>Standard behavior</TH>
    <TH>Microsoft behavior</TH>
</TR>
<TR>
    <TD ROWSPAN=2>
        <SPAN STYLE="writing-mode: vertical-lr;
                     -ms-writing-mode: tb-rl;
                     transform: rotate(180deg);">Nonthrowing</SPAN></TD>
    <TD><CODE>noexcept</CODE><BR>
        <CODE>noexcept(true)</CODE></TD>
    <TD><CODE>std::terminate</CODE></TD>
    <TD><CODE>std::terminate</CODE></TD>
</TR>
<TR>
    <TD><CODE>throw()</CODE><BR></TD>
    <TD><CODE>std::terminate</CODE></TD>
    <TD><CODE>std::terminate</CODE></TD>
</TR>
<TR>
    <TD ROWSPAN=2>
        <SPAN STYLE="writing-mode: vertical-lr;
                     -ms-writing-mode: tb-rl;
                     transform: rotate(180deg);">Throwing</SPAN></TD>
    <TD><CODE>noexcept(false)</CODE></TD>
    <TD>exception propagates</TD>
    <TD>exception propagates</TD>
</TR>
<TR>
    <TD><CODE>throw(something)</CODE></TD>
    <TD>not supported</TD>
    <TD>not supported</TD>
</TR>
</TABLE>

Here’s the result:

SpecifierStandard behaviorMicrosoft behavior
Nonthrowingnoexcept
noexcept(true)
std::terminatestd::terminate
throw()std::terminatestd::terminate
Throwingnoexcept(false)exception propagatesexception propagates
throw(something)not supportednot supported

The first trick is to use writing-mode: vertical-lr to get the text to run vertically. By itself, the text runs top to bottom, but we want it to run bottom to top, so we spin it around it with the transform: rotate(180deg). The default transform origin is the center of the element, so this works out great.

Update: Also add -ms-writing-mode for Internet Explorer.

The second trick is applying those attributes to an inner SPAN element, rather than on the parent TD. This gets the box calculations right for the table cell.

You can apply colors to the various table cells if you want a colored table.

Here’s the same table in wikitable form, because I had need for that too.

 {| class="wikitable"
|-
! colspan="2" | Specifier
! Standard behavior
! Microsoft behavior
|-
| rowspan="2" | <span style="writing-mode: vertical-lr; -ms-writing-mode: tb-rl; transform: rotate(180deg)">Nonthrowing</span>
| <code>noexcept</code><br/><code>noexcept(true)</code>
| <code>std::terminate</code>
| <code>std::terminate</code>
|-
| <code>throw()</code>
| <code>std::terminate</code>
| <code>std::terminate</code>
|-
| rowspan="2" | <span style="writing-mode: vertical-lr; -ms-writing-mode: tb-rl; transform: rotate(180deg)">Throwing</span>
| <code>noexcept(false)</code>
| exception propagates
| exception propagates
|-
| <code>throw(something)</code>
| not supported
| not supported
|-
|}

Raymond Chen
Raymond Chen

Follow Raymond