Very simple C++ question. This is the Aspose slides C++ library.
SharedPtr<MemoryStream> stream = MakeObject<MemoryStream>();
The line above works. But how can I make stream const?
const SharedPtr<MemoryStream> stream = MakeObject<MemoryStream>();
This just returns SharedPtr. How can I make it "const SharedPtr"?
yes I'm not super experienced with C++..
EDIT:
Some more info:
So I need const because I need to pass the result to a function which expects const SharedPtr<T>
as argument.
void Save (const SharedPtr< System::IO::Stream > &stream, const Imaging::ImageFormatPtr &format)
The problems is:
const SharedPtr<MemoryStream> stream = MakeObject<MemoryStream>();
does not return const SharedPtr<T>,
it just returns SharedPtr<T>
for some reason. That's the strange thing.
This is the relevant segment from my code:
const ImageFormatPtr png = System::Drawing::Imaging::ImageFormat::get_Png();
const ImageFormatPtr jpeg = System::Drawing::Imaging::ImageFormat::get_Jpeg();
if (format != "png" && format != "jpeg")
{
throw Php::Exception("Invalid format: " + format);
}
try
{
SharedPtr<System::Drawing::Bitmap> bmp = _slide->GetThumbnail(scaleX, scaleY);
// This is not const!
const SharedPtr<MemoryStream> stream = MakeObject<MemoryStream>();
// ... stream is supposed to be const here
bmp->Save(stream, format == "png" ? png : jpeg);
Thanks in advance!