You need a nice preprocessor (like m4 maybe?) and a whole lot of effort.
Don’t waste your time.
Use the language as designed.
Why not?
Because cout "Hello, " + name + ".\n"; is not C++.
If you wish to use C++, then stick to C++ syntax.
Some keyboards do not have < and > on them.
If this is your rationale, you need to figure out how to handle that problem instead of dinking with C++ syntax. There is a useful thread on Stack Exchange that may help you:
#include <iostream>
#include <string>
#include <concepts>
#include <iomanip>
namespace fancy_plus // best not to pollute the global unnamed namespace
{
template < typename T > // output_streamable type - an object of type T can be sent to std::ostream
concept output_streamable = requires( std::ostream& stm, const T& v )
{ { stm << v } -> std::same_as<std::ostream&> ; } ;
template < output_streamable T > // T is an output_streamable type
std::ostream& operator + ( std::ostream& stm, const T& v ) { return stm << v ; }
}
int main()
{
using fancy_plus::operator+ ; // bring fancy_plus::operator+ into scope
const std::string str = "abcd" ;
std::cout + "string " + std::quoted(str) + " int " + std::setfill('*') + std::setw(7) + 1234
+ " double " + std::fixed + std::setprecision(8) + 56.78 + '\n' ;
}
If we need to refer to the Cpp17UnaryTypeTraitstd::is_pod<T> in C++20,
A POD class is a class that is both a trivial class and a standard-layout class, and has no non-static data members of type non-POD class (or array thereof). A POD type is a scalar type, a POD class, an array of such a type, or a cv-qualified version of one of these types. https://eel.is/c++draft/depr.meta.types#4
The GNU and LLVM compilers warn:
std::is_pod is deprecated: use is_standard_layout && is_trivial instead
std::is_pod and std::is_pod_v are deprecated in C++20. The
std::is_trivially_copyable and/or std::is_standard_layout traits likely suit your use case.
You can define _SILENCE_CXX20_IS_POD_DEPRECATION_WARNING or
_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
A POD type is both "trivial" and "standard-layout". So the concept "POD" has been split in two.
Simplifying a little, a type is trivial if default construction & destruction does nothing and copy/move assignments & constructors are deleted or defaulted on their first declaration.
This means trivial types have no virtual member functions, because that would require a virtual table pointer to be assigned on construction. It also means that any copy/assignment operations behave like a memmove call.
Likewise, a type is standard layout if it follows the same memory layout rules as C.
Trivial types can have performance advantages and standard layout types are useful for interoperation with other tools. These concepts are useful separately, so this is partly why is_pod is deprecated.
? if you can't type << you can't make the macros either.
if you can get it from a virtual keyboard or char mapper or whatever, once, you can copy it afterwards so the macro is moot.
most macros let you do cool hacks that are not fit to be used in serious code. Fun, amusing, etc but terrible code.
I would rather see aprintf than a macro like that.
The term POD is no longer used by the standard, and its type traits (std::is_pod etc.) are deprecated.
A POD type is both "trivial" and "standard-layout". So the concept "POD" has been split in two.
This is where language-lawyering in C++ just keeps getting more and more stoopid.
The language is already huge, and while managing concepts properly is indeed important, taking the time to remove a common, valid, historic type-introspection function for something wordier is a waste of entropy.