]> git.hungrycats.org Git - bees/commitdiff
chatter, fd: drop unused ChatterTraits specializations
authorZygo Blaxell <bees@furryterror.org>
Tue, 28 Apr 2026 21:25:38 +0000 (17:25 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 2 May 2026 03:48:57 +0000 (23:48 -0400)
Remove three template specializations that turned out to be dead
code on inspection:

  - ChatterTraits<const Argument *> in chatter.h: the pointer
    pretty-print that emitted "(pointer to TypeName)(0xaddr)".
    A link-time audit (extern undefined symbol inserted in the
    template body, full build) confirmed no translation unit in
    either the library or its consumers instantiates this
    specialization.  The format had not been used anywhere in
    practice.

  - ChatterTraits<const char *> in chatter.h: existed only to
    override the pointer specialization for C-strings (which would
    otherwise pretty-print every literal as "(pointer to char)
    (0xaddr)").  Once the pointer specialization is gone, the
    primary ChatterTraits<T> template's `c.get_os() << arg` falls
    through to `ostream::operator<<(const char *)`, producing the
    same correct output without a dedicated specialization.

  - ChatterTraits<Fd> in fd.cc: transitively dead.  Its body
    contained `c << &fd` where `&fd` has type `const Fd *`, which
    would have triggered the now-removed pointer specialization
    had any caller used it.  The author's own comment
    (`// XXX: necessary?  useful?`) reflected the same uncertainty;
    the audit confirmed the answer.  Callers that need to print
    an Fd in a log message can use Fd::operator int() for the
    file-descriptor number or name_fd(const Fd&) for the resolved
    path — both already in the public API.

Three template specializations removed; the primary ChatterTraits<T>
template that delegates to `ostream::operator<<` remains as the
single dispatch path.  No behavior change for any existing caller
(audit guarantees these specializations were unreachable).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
include/crucible/chatter.h
lib/fd.cc

index b491dbf0f25c58ed98d8c3e35a7841b0663781d5..c7268c4cec2b5eddfd1ecf5b22991b8385997960 100644 (file)
@@ -69,29 +69,6 @@ namespace crucible {
                return ChatterTraits<T>()(*this, arg);
        }
 
-       template <class Argument>
-       struct ChatterTraits<const Argument *> {
-               Chatter &operator()(Chatter &c, const Argument *arg)
-               {
-                       if (arg) {
-                               c.get_os() << "(pointer to " << typeid(*arg).name() << ")(" << reinterpret_cast<const void *>(arg) << ")";
-                       } else {
-                               c.get_os() << "(NULL pointer to " << typeid(arg).name() << ')';
-                       }
-                       return c;
-               }
-       };
-
-       template <>
-       struct ChatterTraits<const char *> {
-               Chatter &
-               operator()(Chatter &c, const char *arg)
-               {
-                       c.get_os() << arg;
-                       return c;
-               }
-       };
-
        class ChatterBox {
                string m_file;
                int m_line;
index d147eeb5e1aeecc4a36d31da8e370391b2b31207..598b520926b68dc752828de088e8208bc0e35ce6 100644 (file)
--- a/lib/fd.cc
+++ b/lib/fd.cc
@@ -162,16 +162,6 @@ namespace crucible {
                return m_handle;
        }
 
-       // XXX: necessary?  useful?
-       template <>
-       struct ChatterTraits<Fd> {
-               Chatter &operator()(Chatter &c, const Fd &fd) const
-               {
-                       c << "Fd {this=" << &fd << " fd=" << static_cast<int>(fd) << "}";
-                       return c;
-               }
-       };
-
        int
        open_or_die(const string &file, int flags, mode_t mode)
        {