cpp: add template_streamop generation with runtime/compiler test coverage

Add template_streamop support in the C++ generator so generated operator<< and printTo can target generic stream-like output types.
Keep default behavior unchanged when the option is not set (std::ostream signatures remain).
Add compiler/runtime coverage for template generation, friend declaration correctness, enums, and collection printing.

default:
```cpp
std::ostream& operator<<(std::ostream& out, const SimpleStruct& obj);

class SimpleStruct {
public:
  void printTo(std::ostream& out) const;
};
```

with `template_streamop`:
```cpp
template <typename OStream_>
OStream_& operator<<(OStream_& out, const SimpleStruct& obj);

class SimpleStruct {
public:
  template <typename OStream_>
  void printTo(OStream_& out) const;
};
```
diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt
index 2403c87..6fdc95e 100644
--- a/test/cpp/CMakeLists.txt
+++ b/test/cpp/CMakeLists.txt
@@ -164,6 +164,29 @@
 target_link_libraries(EnumClassTest thrift)
 add_test(NAME EnumClassTest COMMAND EnumClassTest)
 
+# TemplateStreamOpTest - tests the template_streamop option
+set(templatestreamoptestgencpp_SOURCES
+    gen-cpp-templatestreamop/gen-cpp/ThriftTest_types.cpp
+    gen-cpp-templatestreamop/gen-cpp/ThriftTest_constants.cpp
+    src/ThriftTest_extras.cpp
+)
+add_library(templatestreamoptestgencpp STATIC ${templatestreamoptestgencpp_SOURCES})
+target_include_directories(templatestreamoptestgencpp BEFORE PRIVATE 
+    "${CMAKE_CURRENT_BINARY_DIR}/gen-cpp-templatestreamop"
+    "${CMAKE_CURRENT_BINARY_DIR}"
+    "${PROJECT_SOURCE_DIR}/lib/cpp/src"
+)
+target_link_libraries(templatestreamoptestgencpp thrift)
+
+add_executable(TemplateStreamOpTest src/TemplateStreamOpTest.cpp)
+target_include_directories(TemplateStreamOpTest BEFORE PRIVATE 
+    "${CMAKE_CURRENT_BINARY_DIR}/gen-cpp-templatestreamop/gen-cpp"
+    "${CMAKE_CURRENT_BINARY_DIR}/gen-cpp-templatestreamop"
+)
+target_link_libraries(TemplateStreamOpTest templatestreamoptestgencpp ${Boost_LIBRARIES})
+target_link_libraries(TemplateStreamOpTest thrift)
+add_test(NAME TemplateStreamOpTest COMMAND TemplateStreamOpTest)
+
 #
 # Common thrift code generation rules
 #
@@ -193,6 +216,13 @@
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 )
 
+# Generate ThriftTest with template_streamop option for TemplateStreamOpTest
+add_custom_command(OUTPUT gen-cpp-templatestreamop/gen-cpp/ThriftTest_types.cpp gen-cpp-templatestreamop/gen-cpp/ThriftTest_types.h gen-cpp-templatestreamop/gen-cpp/ThriftTest_constants.cpp
+    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/gen-cpp-templatestreamop
+    COMMAND ${THRIFT_COMPILER} --gen cpp:template_streamop -o gen-cpp-templatestreamop ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
+
 add_custom_command(OUTPUT gen-cpp/Service.cpp
     COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
 )