Skip to content

Enum has no buffer #2

@imtrobin

Description

@imtrobin

Hi, I tested with enum with default value 0, the buffer stored is empty. v0.9.9

Repro

#include "SimpleBinStream/SimpleBinStream.h"
#include <iostream>
#include <sstream>
using namespace std;

enum TestEnum : unsigned char
{
	  EnumOne
	, EnumTwo
	, EnumThree

// If I use this, then the buffer shows out properly
// 	 EnumOne    = 1 
// 	, EnumTwo   = 2 
// 	, EnumThree = 3

	, End
};

int main (int argc, char * argv [])
{
	simple::mem_ostream <std::true_type>  out;

	// this is problem
	out << TestEnum::EnumOne;
	// this is fine
	//out << TestEnum::EnumOne;

	const char * buffer = reinterpret_cast <const char*> (out.get_internal_vec ().data ());
	int buffersize = out.get_internal_vec ().size ();

	// Output buffer here is nothing unless I assign values to the enum
 	cout << "out\nBufferSize:" << buffersize << " buffer:" << buffer << "*" << endl;
	return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions