mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Optional: Move optional-lite to the include/third-party directory
This fixes the use case of adding the include folder manually to an outside project.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#include "nonstd/optional.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using nonstd::optional;
|
||||
|
||||
struct V
|
||||
{
|
||||
int v;
|
||||
|
||||
V( int v )
|
||||
: v( v ) {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
int x = 42;
|
||||
// V s; // V has no default constructor
|
||||
V t(x); // Ok
|
||||
|
||||
std::vector< optional<V> > v(3);
|
||||
v[0] = t;
|
||||
|
||||
std::cout << "v[0].value().v: " << v[0].value().v << "\n";
|
||||
std::cout << "v[1].value().v: " << v[1].value().v << "\n";
|
||||
}
|
||||
catch( std::exception const & e )
|
||||
{
|
||||
std::cout << "Error: " << e.what() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// cl -nologo -W3 -EHsc -I../include 00-nodefltctor.cpp && 00-nodefltctor
|
||||
Reference in New Issue
Block a user