Define operator<< in the corresponding namespace

This fixes the build for me with clang 11.1.0 (from LLVM repositories) on
Debian buster as C++11.  As far as I know this is the general best practice
because of ADL voodoo, but Ardour's approach to namespaces is pretty anarchic,
and I'm not really sure exactly why this wasn't building for some types.

Also tested to build find with the default buster GCC 8.3.0.
This commit is contained in:
David Robillard 2021-05-28 12:23:48 -04:00
parent c2687d156e
commit 40ad977046
28 changed files with 66 additions and 78 deletions

View file

@ -178,8 +178,8 @@ public:
int channel; ///< channel index, or -1 for "all" int channel; ///< channel index, or -1 for "all"
}; };
std::ostream & operator<< (std::ostream & o, Bundle const &);
} }
std::ostream & operator<< (std::ostream & o, ARDOUR::Bundle const &);
#endif /* __ardour_bundle_h__ */ #endif /* __ardour_bundle_h__ */

View file

@ -212,9 +212,9 @@ private:
uint32_t _counts[DataType::num_types]; uint32_t _counts[DataType::num_types];
}; };
} // namespace ARDOUR LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ChanCount& c);
LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::ChanCount& c); } // namespace ARDOUR
#endif // __ardour_chan_count_h__ #endif // __ardour_chan_count_h__

View file

@ -136,9 +136,9 @@ private:
Mappings _mappings; Mappings _mappings;
}; };
} // namespace ARDOUR std::ostream& operator<<(std::ostream& o, const ChanMapping& m);
std::ostream& operator<<(std::ostream& o, const ARDOUR::ChanMapping& m); } // namespace ARDOUR
#endif // __ardour_chan_mapping_h__ #endif // __ardour_chan_mapping_h__

View file

@ -447,8 +447,8 @@ private:
GATOMIC_QUAL gint _flush; GATOMIC_QUAL gint _flush;
}; };
std::ostream& operator<<(std::ostream& o, const PluginInsert::Match& m);
} // namespace ARDOUR } // namespace ARDOUR
std::ostream& operator<<(std::ostream& o, const ARDOUR::PluginInsert::Match& m);
#endif /* __ardour_plugin_insert_h__ */ #endif /* __ardour_plugin_insert_h__ */

View file

@ -280,8 +280,8 @@ class LIBARDOUR_API PresentationInfo : public PBD::Stateful
static int selection_counter; static int selection_counter;
}; };
LIBARDOUR_API std::ostream& operator<<(std::ostream& o, PresentationInfo const& rid);
} }
std::ostream& operator<<(std::ostream& o, ARDOUR::PresentationInfo const& rid);
#endif /* __libardour_presentation_info_h__ */ #endif /* __libardour_presentation_info_h__ */

View file

@ -627,11 +627,11 @@ private:
MeterSection* copy_metrics_and_point (const Metrics& metrics, Metrics& copy, MeterSection* section) const; MeterSection* copy_metrics_and_point (const Metrics& metrics, Metrics& copy, MeterSection* section) const;
}; };
}; /* namespace ARDOUR */ LIBARDOUR_API std::ostream& operator<< (std::ostream&, const Meter&);
LIBARDOUR_API std::ostream& operator<< (std::ostream&, const Tempo&);
LIBARDOUR_API std::ostream& operator<< (std::ostream&, const MetricSection&);
LIBARDOUR_API std::ostream& operator<< (std::ostream&, const ARDOUR::Meter&); }; /* namespace ARDOUR */
LIBARDOUR_API std::ostream& operator<< (std::ostream&, const ARDOUR::Tempo&);
LIBARDOUR_API std::ostream& operator<< (std::ostream&, const ARDOUR::MetricSection&);
namespace PBD { namespace PBD {
DEFINE_ENUM_CONVERT (ARDOUR::TempoSection::Type) DEFINE_ENUM_CONVERT (ARDOUR::TempoSection::Type)

View file

@ -66,8 +66,9 @@ ChanCount::state(const std::string& name) const
// Statics // Statics
const ChanCount ChanCount::ZERO = ChanCount(); const ChanCount ChanCount::ZERO = ChanCount();
} // namespace ARDOUR std::ostream& operator<<(std::ostream& o, const ChanCount& c) {
std::ostream& operator<<(std::ostream& o, const ARDOUR::ChanCount& c) {
return o << "AUDIO=" << c.n_audio() << ":MIDI=" << c.n_midi(); return o << "AUDIO=" << c.n_audio() << ":MIDI=" << c.n_midi();
} }
} // namespace ARDOUR

View file

@ -257,16 +257,12 @@ ChanMapping::count () const
return rv; return rv;
} }
std::ostream& operator<<(std::ostream& o, const ChanMapping& cm)
} // namespace ARDOUR
std::ostream& operator<<(std::ostream& o, const ARDOUR::ChanMapping& cm)
{ {
const ARDOUR::ChanMapping::Mappings& mp (cm.mappings()); const ChanMapping::Mappings& mp (cm.mappings());
for (ARDOUR::ChanMapping::Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) { for (ChanMapping::Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) {
o << tm->first.to_string() << endl; o << tm->first.to_string() << endl;
for (ARDOUR::ChanMapping::TypeMapping::const_iterator i = tm->second.begin(); for (ChanMapping::TypeMapping::const_iterator i = tm->second.begin();
i != tm->second.end(); ++i) { i != tm->second.end(); ++i) {
o << "\t" << i->first << " => " << i->second << endl; o << "\t" << i->first << " => " << i->second << endl;
} }
@ -274,3 +270,5 @@ std::ostream& operator<<(std::ostream& o, const ARDOUR::ChanMapping& cm)
return o; return o;
} }
} // namespace ARDOUR

View file

@ -264,6 +264,7 @@ LTC_TransportMaster::equal_ltc_sample_time(LTCFrame *a, LTCFrame *b) {
} }
return true; return true;
} }
static ostream& operator<< (ostream& ostr, LTCFrame& a) static ostream& operator<< (ostream& ostr, LTCFrame& a)
{ {
ostr ostr

View file

@ -3382,7 +3382,7 @@ PluginInsert::clear_stats ()
g_atomic_int_set (&_stat_reset, 1); g_atomic_int_set (&_stat_reset, 1);
} }
std::ostream& operator<<(std::ostream& o, const ARDOUR::PluginInsert::Match& m) std::ostream& ARDOUR::operator<<(std::ostream& o, const ARDOUR::PluginInsert::Match& m)
{ {
switch (m.method) { switch (m.method) {
case PluginInsert::Impossible: o << "Impossible"; break; case PluginInsert::Impossible: o << "Impossible"; break;

View file

@ -297,7 +297,7 @@ PresentationInfo::operator= (PresentationInfo const& other)
} }
std::ostream& std::ostream&
operator<<(std::ostream& o, ARDOUR::PresentationInfo const& pi) ARDOUR::operator<<(std::ostream& o, ARDOUR::PresentationInfo const& pi)
{ {
return o << pi.order() << '/' << enum_2_string (pi.flags()) << '/' << pi.color(); return o << pi.order() << '/' << enum_2_string (pi.flags()) << '/' << pi.color();
} }

View file

@ -3230,17 +3230,11 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool
} }
} }
#if !defined(__APPLE__) && !defined(__FreeBSD__)
/* clang complains: 'operator<<' should be declared prior to the call site or in an associated namespace of one of its
* arguments std::ostream& operator<<(std::ostream& o, ARDOUR::PresentationInfo const& rid)"
*/
DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("added route %1, group order %2 type %3 (summary: %4)\n", DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("added route %1, group order %2 type %3 (summary: %4)\n",
r->name(), r->name(),
r->presentation_info().order(), r->presentation_info().order(),
enum_2_string (r->presentation_info().flags()), enum_2_string (r->presentation_info().flags()),
r->presentation_info())); r->presentation_info()));
#endif
if (input_auto_connect || output_auto_connect) { if (input_auto_connect || output_auto_connect) {
auto_connect_route (r, input_auto_connect, output_auto_connect, ChanCount (), ChanCount (), existing_inputs, existing_outputs); auto_connect_route (r, input_auto_connect, output_auto_connect, ChanCount (), ChanCount (), existing_inputs, existing_outputs);

View file

@ -4943,17 +4943,17 @@ struct bbtcmp {
}; };
std::ostream& std::ostream&
operator<< (std::ostream& o, const Meter& m) { ARDOUR::operator<< (std::ostream& o, const ARDOUR::Meter& m) {
return o << m.divisions_per_bar() << '/' << m.note_divisor(); return o << m.divisions_per_bar() << '/' << m.note_divisor();
} }
std::ostream& std::ostream&
operator<< (std::ostream& o, const Tempo& t) { ARDOUR::operator<< (std::ostream& o, const ARDOUR::Tempo& t) {
return o << t.note_types_per_minute() << " 1/" << t.note_type() << "'s per minute"; return o << t.note_types_per_minute() << " 1/" << t.note_type() << "'s per minute";
} }
std::ostream& std::ostream&
operator<< (std::ostream& o, const MetricSection& section) { ARDOUR::operator<< (std::ostream& o, const ARDOUR::MetricSection& section) {
o << "MetricSection @ " << section.sample() << ' '; o << "MetricSection @ " << section.sample() << ' ';

View file

@ -323,8 +323,8 @@ private:
void scrolled (); void scrolled ();
}; };
std::ostream& operator<< (std::ostream&, const Canvas&);
} }
std::ostream& operator<< (std::ostream&, const ArdourCanvas::Canvas&);
#endif #endif

View file

@ -333,7 +333,7 @@ private:
void propagate_show_hide (); void propagate_show_hide ();
}; };
extern LIBCANVAS_API std::ostream& operator<< (std::ostream&, const ArdourCanvas::Item&); extern LIBCANVAS_API std::ostream& operator<< (std::ostream&, const Item&);
} }

View file

@ -104,12 +104,11 @@ ControlSet::clear_controls ()
} }
} }
} // namespace Evoral
/* No good place for this so just put it here */
std::ostream& std::ostream&
std::operator<< (std::ostream & str, Evoral::Parameter const & p) operator<< (std::ostream & str, Parameter const & p)
{ {
return str << p.type() << '-' << p.id() << '-' << (int) p.channel(); return str << p.type() << '-' << p.id() << '-' << (int) p.channel();
} }
} // namespace Evoral

View file

@ -87,11 +87,9 @@ private:
uint8_t _channel; uint8_t _channel;
}; };
} // namespace Evoral std::ostream& operator<< (std::ostream &str, Parameter const &);
namespace std { } // namespace Evoral
std::ostream& operator<< (std::ostream &str, Evoral::Parameter const &);
}
#endif // EVORAL_PARAMETER_HPP #endif // EVORAL_PARAMETER_HPP

View file

@ -371,11 +371,9 @@ private:
uint8_t _highest_note; uint8_t _highest_note;
}; };
template<typename Time> /*LIBEVORAL_API*/ std::ostream& operator<<(std::ostream& o, const Evoral::Sequence<Time>& s) { s.dump (o); return o; }
} // namespace Evoral } // namespace Evoral
template<typename Time> /*LIBEVORAL_API*/ std::ostream& operator<<(std::ostream& o, const Evoral::Sequence<Time>& s) { s.dump (o); return o; }
#endif // EVORAL_SEQUENCE_HPP #endif // EVORAL_SEQUENCE_HPP

View file

@ -105,7 +105,7 @@ ID::operator= (const ID& other)
} }
ostream& ostream&
operator<< (ostream& ostr, const ID& id) PBD::operator<< (ostream& ostr, const ID& id)
{ {
ostr << id.to_s(); ostr << id.to_s();
return ostr; return ostr;

View file

@ -75,8 +75,8 @@ class LIBPBD_API ID {
static uint64_t _counter; static uint64_t _counter;
}; };
LIBPBD_API std::ostream& operator<< (std::ostream& ostr, const ID&);
} }
LIBPBD_API std::ostream& operator<< (std::ostream& ostr, const PBD::ID&);
#endif /* __pbd_id_h__ */ #endif /* __pbd_id_h__ */

View file

@ -88,9 +88,9 @@ public:
bool _in_use; bool _in_use;
}; };
}
}
std::ostream & operator<< (std::ostream & os, const ArdourSurface::Mackie::Control & control); std::ostream & operator<< (std::ostream & os, const ArdourSurface::Mackie::Control & control);
}
}
#endif /* __mackie_controls_h__ */ #endif /* __mackie_controls_h__ */

View file

@ -127,10 +127,9 @@ class DeviceInfo
void shared_buttons (); void shared_buttons ();
}; };
std::ostream& operator<< (std::ostream& os, const ArdourSurface::Mackie::DeviceInfo& di);
} // Mackie namespace } // Mackie namespace
} // ArdourSurface namespace } // ArdourSurface namespace
std::ostream& operator<< (std::ostream& os, const ArdourSurface::Mackie::DeviceInfo& di);
#endif /* __ardour_mackie_control_protocol_device_info_h__ */ #endif /* __ardour_mackie_control_protocol_device_info_h__ */

View file

@ -88,9 +88,9 @@ public:
bool _in_use; bool _in_use;
}; };
}
}
std::ostream & operator<< (std::ostream & os, const ArdourSurface::US2400::Control & control); std::ostream & operator<< (std::ostream & os, const ArdourSurface::US2400::Control & control);
}
}
#endif /* __us2400_controls_h__ */ #endif /* __us2400_controls_h__ */

View file

@ -122,10 +122,9 @@ class DeviceInfo
void shared_buttons (); void shared_buttons ();
}; };
std::ostream& operator<< (std::ostream& os, const ArdourSurface::US2400::DeviceInfo& di);
} // US2400 namespace } // US2400 namespace
} // ArdourSurface namespace } // ArdourSurface namespace
std::ostream& operator<< (std::ostream& os, const ArdourSurface::US2400::DeviceInfo& di);
#endif /* __ardour_us2400_control_protocol_device_info_h__ */ #endif /* __ardour_us2400_control_protocol_device_info_h__ */

View file

@ -112,24 +112,22 @@ struct LIBTEMPORAL_API BBT_Offset
BBT_Offset (double beats); BBT_Offset (double beats);
}; };
}
inline std::ostream& inline std::ostream&
operator<< (std::ostream& o, const Timecode::BBT_Time& bbt) operator<< (std::ostream& o, const BBT_Time& bbt)
{ {
o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks; o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks;
return o; return o;
} }
inline std::ostream& inline std::ostream&
operator<< (std::ostream& o, const Timecode::BBT_Offset& bbt) operator<< (std::ostream& o, const BBT_Offset& bbt)
{ {
o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks; o << bbt.bars << '|' << bbt.beats << '|' << bbt.ticks;
return o; return o;
} }
inline std::ostream& inline std::ostream&
print_padded (std::ostream& o, const Timecode::BBT_Time& bbt) print_padded (std::ostream& o, const BBT_Time& bbt)
{ {
o << std::setfill ('0') << std::right o << std::setfill ('0') << std::right
<< std::setw (3) << bbt.bars << "|" << std::setw (3) << bbt.bars << "|"
@ -139,4 +137,6 @@ print_padded (std::ostream& o, const Timecode::BBT_Time& bbt)
return o; return o;
} }
}
#endif /* __timecode_bbt_time_h__ */ #endif /* __timecode_bbt_time_h__ */

View file

@ -162,8 +162,8 @@ sample_to_timecode (
uint32_t subframes_per_frame, uint32_t subframes_per_frame,
bool offset_is_negative, int64_t offset_samples); bool offset_is_negative, int64_t offset_samples);
extern LIBTEMPORAL_API std::ostream& operator<< (std::ostream& ostr, const Time& t);
} // namespace Timecode } // namespace Timecode
extern LIBTEMPORAL_API std::ostream& operator<< (std::ostream& ostr, const Timecode::Time& t);
#endif // __timecode_time_h__ #endif // __timecode_time_h__

View file

@ -844,10 +844,11 @@ sample_to_timecode (
timecode.drop = timecode_drop_frames; timecode.drop = timecode_drop_frames;
} }
} // namespace Timecode
std::ostream& std::ostream&
operator<<(std::ostream& ostr, const Timecode::Time& t) operator<<(std::ostream& ostr, const Time& t)
{ {
return t.print (ostr); return t.print (ostr);
} }
} // namespace Timecode

View file

@ -420,10 +420,10 @@ class LIBARDOUR_API TempoMap
void dump_locked (std::ostream&); void dump_locked (std::ostream&);
}; };
std::ostream& operator<<(std::ostream&, TempoMapPoint const &);
std::ostream& operator<<(std::ostream&, Tempo const &);
std::ostream& operator<<(std::ostream&, Meter const &);
} }
std::ostream& operator<<(std::ostream&, ARDOUR::TempoMapPoint const &);
std::ostream& operator<<(std::ostream&, ARDOUR::Tempo const &);
std::ostream& operator<<(std::ostream&, ARDOUR::Meter const &);
#endif /* __ardour_tempo_h__ */ #endif /* __ardour_tempo_h__ */