
On 27 January 2012 12:57, Simonson, Lucanus J <lucanus.j.simonson@intel.com> wrote:
Optional was implemented to be safe and slow because it was targeting safe and slow use cases.
You are saying it is *deliberately* slow??
For POD types and anything that has a default constructor a std::pair<bool, T> seems fine to me.
I don't want to write a different style of code depending on whether or not a type T is default constructible. I can't easily pass things like this to templates because I have to write special cases all over the place. Optional models my intent. I want to take advantage of RVO. Some things that are default constructible are still very expensive to construct (such as std::deque under gcc). When you initialize class members, do you use member intializer lists for default constructible types or do you just throw a bunch of assignments in the body of the constructor? If the former, why do you do it, given that default construction followed by assignment "seems fine" to you? -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404