boost-optional Questions

6

Solved

Why std::optional (std::experimental::optional in libc++ at the moment) does not have specialization for reference types (compared with boost::optional)? I think it would be very useful option. Is ...
Odontoblast asked 11/11, 2014 at 5:18

3

Solved

How can I make a raw pointer behave like a range, for a for-range loop syntax. double five = 5; double* dptr = &five; for(int& d : dptr) std::cout << d << std::endl;// will not...
Elevon asked 30/1, 2015 at 18:10

2

Solved

Consider the following example where we parse data and pass the result to the next function: Content Parse(const std::string& data); void Process(Content content); int main() { auto data = R...
Indubitability asked 6/7, 2013 at 11:37

0

Time to time gcc gives warning about work with boost::optional via maybe-uninitialized , but I have supposed that this is false positive (like described here https://github.com/boostorg/optional/is...
Diabolism asked 2/7, 2019 at 21:5

1

Solved

I want to create headers which use 'optional' from standard C++. However, My headers will be referred from Visual Studio 2015 as well as Visual Studio 2017 projects. I would like to have something...
Antidromic asked 18/9, 2018 at 4:59

3

Solved

I'm stuck with a compile-time error which I cannot understand. I try to use boost::optional in my code, and as soon as I include boost/optional.hpp I cannot build my project any longer. If I commen...
Quincey asked 18/10, 2016 at 12:42

1

Solved

I suspect boost::optional's get_value_or was deprecated because it is unsafe if an rvalue is passed as the default parameter. However, it is occasionally useful to be able to reference the optional...
Elam asked 17/4, 2018 at 7:48

4

Is it possible to implement std::optional such that sizeof(std::optional<double>) == 8 by somehow using that you can store characters in a NAN, see http://en.cppreference.com/w/cpp/numeric/ma...
Trichoid asked 4/8, 2017 at 15:39

7

Solved

From what I understand there are 2* ways you can implement a function that sometimes doesnt return a result(for example is person found in a list of ppl). *- we ignore raw ptr version, pair with ...
Middleweight asked 16/1, 2013 at 14:31

4

Solved

I have code similar to the following: #include <boost/optional.hpp> ::boost::optional<int> getitem(); int go(int nr) { boost::optional<int> a = getitem(); boost::optional<...
Ganesha asked 13/2, 2014 at 13:9

2

Solved

I have a function whose signature is: void func(std::optional<std::string> os = std::nullopt); (I’m aliasing std::experimental::optional until std::optional is officially available.) Howe...
Sammons asked 6/2, 2017 at 0:41

3

Solved

How I can prevent the last line of this code from compiling? #include <boost/optional.hpp> int main() { typedef boost::optional<int> int_opt; int_opt opt = 0; bool x = opt; // <...
Intracellular asked 7/2, 2011 at 15:57

1

Solved

Usually when a function returns boost::optional I've seen a lot of people returning an empty brace {} to designate an empty value, that works fine and is shorter than returning boost::none. I trie...
Chauvin asked 2/11, 2016 at 23:4

4

Solved

I'm reading the documentation of std::experimental::optional and I have a good idea about what it does, but I don't understand when I should use it or how I should use it. The site doesn't contain ...
Ing asked 31/5, 2013 at 15:35

1

Solved

Assume we have a function which returns std::optional<A>. Then what is a proper way of using the result in the range-based for loop? The easiest way does not work: for (auto&& e : a(...
Amygdaloid asked 4/6, 2016 at 23:13

2

Solved

I am experimenting with implementing boost::optional like data structure using c++11 features. Here is what I have so far : template<typename T> struct maybe { bool valid; union { T valu...
Infrequency asked 9/8, 2012 at 0:12

3

Solved

Suppose a method returns something like this boost::optional<SomeClass> SomeMethod() {...} Now suppose I have something like this boost::optional<SomeClass> val = SomeMethod(); No...
Monopolist asked 5/6, 2013 at 19:57

1

Is there a way to wrap boost::optional<T> type object to expose it via boost::python::class_ (used from BOOST_PYTHON_MODULE) struct Foo { boost::optional<int> bar; }; BOOST_PYTHON_...
Anatole asked 7/4, 2016 at 19:48

4

If I have a find function that can sometimes fail to find the required thing, I tend to make that function return a pointer such that a nullptr indicates that the thing was not found. E.g. ...
Pyxis asked 9/2, 2016 at 15:59

3

Solved

If I try to look at the variable directly, I see a ? sign. If I create a watch calling the is_initialized function, I get the following error: CXX0033: Error: error in OMF type information I d...
Assonance asked 2/7, 2012 at 20:22

4

Solved

I am trying to use boost::optional as below. #include <iostream> #include <string> #include <boost/optional.hpp> struct myClass { int myInt; void setInt(int input) { myInt =...
Laddy asked 6/3, 2014 at 14:47

3

Solved

I'm trying to get my program working without boost usage, but can't find an alternative of some useful patterns. Namely, I can't find boost::optional-likewise pattern in the standard library. Is th...
Teheran asked 15/1, 2012 at 14:3

1

Solved

I was wondering if there is an elegant way to cast a boost::optional<A> to a boost::optional<B> when B can be constructed from A, albeit explicitely. This works: # include <boost/op...
Fiber asked 5/2, 2015 at 15:3

3

Solved

With Boost I can create an optional in-place with: boost::optional<boost::asio::io_service::work> work = boost::in_place(boost::ref(io_service)); And disengage it with: work = boost::non...
Cleft asked 12/11, 2014 at 21:37

2

Solved

I have a few questions about how boost::optional works. Let's first do this: boost::optional<int> i; Is i < 3 always equivalent to *i < 3 (and similar for other relational operators...
Ebner asked 29/6, 2013 at 23:10

© 2022 - 2024 — McMap. All rights reserved.