Click here to Skip to main content
15,894,907 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to get a string as input ? Pin
Sampath5799-Mar-18 20:15
Sampath5799-Mar-18 20:15 
QuestionRe: how to get a string as input ? Pin
David Crow10-Mar-18 11:07
David Crow10-Mar-18 11:07 
AnswerRe: how to get a string as input ? Pin
Tarun Jha15-Mar-18 7:50
Tarun Jha15-Mar-18 7:50 
QuestionHow can I minimize memory usage in my table-based statemachine with several hundred states? Pin
arnold_w9-Mar-18 9:02
arnold_w9-Mar-18 9:02 
GeneralRe: How can I minimize memory usage in my table-based statemachine with several hundred states? Pin
harold aptroot9-Mar-18 9:54
harold aptroot9-Mar-18 9:54 
GeneralRe: How can I minimize memory usage in my table-based statemachine with several hundred states? Pin
arnold_w9-Mar-18 10:00
arnold_w9-Mar-18 10:00 
GeneralRe: How can I minimize memory usage in my table-based statemachine with several hundred states? Pin
harold aptroot9-Mar-18 10:14
harold aptroot9-Mar-18 10:14 
AnswerRe: How can I minimize memory usage in my table-based statemachine with several hundred states? Pin
leon de boer9-Mar-18 15:16
leon de boer9-Mar-18 15:16 
QuestionHow to get object of a view which is created using AddView(). Pin
Sampath5799-Mar-18 0:38
Sampath5799-Mar-18 0:38 
AnswerRe: How to get object of a view which is created using AddView(). Pin
Victor Nijegorodov9-Mar-18 1:45
Victor Nijegorodov9-Mar-18 1:45 
GeneralRe: How to get object of a view which is created using AddView(). Pin
Sampath57910-Mar-18 23:20
Sampath57910-Mar-18 23:20 
GeneralRe: How to get object of a view which is created using AddView(). Pin
Victor Nijegorodov11-Mar-18 2:05
Victor Nijegorodov11-Mar-18 2:05 
AnswerRe: How to get object of a view which is created using AddView(). Pin
Richard MacCutchan9-Mar-18 5:18
mveRichard MacCutchan9-Mar-18 5:18 
GeneralRe: How to get object of a view which is created using AddView(). Pin
Sampath57911-Mar-18 6:04
Sampath57911-Mar-18 6:04 
GeneralRe: How to get object of a view which is created using AddView(). Pin
Victor Nijegorodov11-Mar-18 7:12
Victor Nijegorodov11-Mar-18 7:12 
GeneralRe: How to get object of a view which is created using AddView(). Pin
Richard MacCutchan11-Mar-18 22:32
mveRichard MacCutchan11-Mar-18 22:32 
QuestionHow to release IDispatch memory. Pin
Sampath5797-Mar-18 2:45
Sampath5797-Mar-18 2:45 
AnswerRe: How to release IDispatch memory. Pin
Jochen Arndt7-Mar-18 3:10
professionalJochen Arndt7-Mar-18 3:10 
GeneralRe: How to release IDispatch memory. Pin
Sampath5798-Mar-18 18:40
Sampath5798-Mar-18 18:40 
GeneralRe: How to release IDispatch memory. Pin
Jochen Arndt8-Mar-18 21:21
professionalJochen Arndt8-Mar-18 21:21 
GeneralRe: How to release IDispatch memory. Pin
Sampath5798-Mar-18 22:27
Sampath5798-Mar-18 22:27 
GeneralRe: How to release IDispatch memory. Pin
Jochen Arndt8-Mar-18 22:55
professionalJochen Arndt8-Mar-18 22:55 
AnswerRe: How to release IDispatch memory. Pin
Randor 7-Mar-18 5:38
professional Randor 7-Mar-18 5:38 
Questionserializing an std::chrono::duration object with Boost Pin
Alexander Kindel7-Mar-18 2:12
Alexander Kindel7-Mar-18 2:12 
Why is it that in the following program, the value of newCount that prints at the end is 10, as I would expect, while the value of newTime.count() that prints is -3689348814741910324?

C++
#include "stdafx.h"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <chrono>
#include <fstream>
#include <iostream>

namespace boost
{
	namespace serialization
	{
		template<class Archive>
		void serialize(Archive&ar, std::chrono::nanoseconds&time, const unsigned int version)
		{
			long long count{ time.count() };
			ar&count;
		}
	}
}

int main()
{
	std::chrono::nanoseconds time(10);
	long long count = time.count();
	{
		std::ofstream saveFile("filename");
		boost::archive::text_oarchive boostOutputArchieve(saveFile);		
		boostOutputArchieve << time;		
		boostOutputArchieve << count;
	}
	std::chrono::nanoseconds newTime;
	long long newCount;
	{
		std::ifstream loadFile("filename");
		boost::archive::text_iarchive boostInputArchieve(loadFile);
		boostInputArchieve >> newTime;
		boostInputArchieve >> newCount;
	}
	std::cout << newTime.count() << '\n' << newCount << '\n';
	return 0;
}


I would have thought setting up the serialize() overload for nanoseconds to serialize the tick count and using that would have the same result as serializing the tick count directly.
AnswerRe: serializing an std::chrono::duration object with Boost Pin
Alexander Kindel7-Mar-18 3:53
Alexander Kindel7-Mar-18 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.