Skip to content

Commit 7065cc7

Browse files
committed
Squashed 'include/tao/optional/akrzemi1/' content from commit 65f52c2
git-subtree-dir: include/tao/optional/akrzemi1 git-subtree-split: 65f52c29bd25056455b8a538e7fa62dc5d1c4222
0 parents  commit 7065cc7

File tree

7 files changed

+2650
-0
lines changed

7 files changed

+2650
-0
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
project(optional)
2+
cmake_minimum_required(VERSION 2.8)
3+
enable_testing()
4+
5+
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra")
6+
7+
add_executable(test_optional test_optional.cpp)
8+
add_executable(test_type_traits test_type_traits.cpp)
9+
10+
add_test(test_optional test_optional)
11+
add_test(test_type_traits test_type_traits)

LICENSE_1_0.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Boost Software License - Version 1.0 - August 17th, 2003
2+
3+
Permission is hereby granted, free of charge, to any person or organization
4+
obtaining a copy of the software and accompanying documentation covered by
5+
this license (the "Software") to use, reproduce, display, distribute,
6+
execute, and transmit the Software, and to prepare derivative works of the
7+
Software, and to permit third-parties to whom the Software is furnished to
8+
do so, all subject to the following:
9+
10+
The copyright notices in the Software and this entire statement, including
11+
the above license grant, this restriction and the following disclaimer,
12+
must be included in all copies of the Software, in whole or in part, and
13+
all derivative works of the Software, unless such copies or derivative
14+
works are solely in the form of machine-executable object code generated by
15+
a source language processor.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Optional
2+
========
3+
4+
A single-header header-only library for representing optional (nullable) objects for C++14 (and C++11 to some extent) and passing them by value. This is the reference implementation of proposal N3793 (see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3793.html). Optional is now accepted into Library Fundamentals Technical Specification (see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3848.html). The interface is based on Fernando Cacciola's Boost.Optional library (see http://www.boost.org/doc/libs/1_52_0/libs/optional/doc/html/index.html)
5+
6+
7+
Usage
8+
-----
9+
10+
```cpp
11+
optional<int> readInt(); // this function may return int or a not-an-int
12+
13+
if (optional<int> oi = readInt()) // did I get a real int
14+
cout << "my int is: " << *oi; // use my int
15+
else
16+
cout << "I have no int";
17+
```
18+
19+
For more usage examples and the overview see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3527.html
20+
21+
22+
Supported compilers
23+
-------------------
24+
25+
Clang 3.2, Clang 3.4, G++ 4.7.2, G++ 4.8.1. Tested only with libstdc++, versions 20130531, 20120920, 20110428. Others have reported it also works with libc++.
26+
27+
28+
29+
Known Issues
30+
------------
31+
32+
- Currently, the reference (and the only known) impementation of certain pieces of functionality explore what C++11 identifies as undefined behavior (see national body comment FI 15: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3770.html#FI15). This is mostly why Optional was removed from C++14 and put into Library Fundamentals TS. Luckily what the Standard identifies as UB is well defined on all known platforms. We expect that the C++14 wil fix this problem, so that our trick becomes well-defined.
33+
- In libstdc++ versions below 20130531 the constructor taking `initializer_list` argument is not `constexpr`. This is because `initializer_list` operations are not `constexpr` in C++11. This works however in version 20130531. It is also not enabled for libc++ because I do not have access to it and do nto know if it provides `constexpr` `initializer_list`.
34+
- In G++ 4.7.2 and 4.8.0 member function `value_or` does not have rvalue reference overload. These compilers do not support rvalue overloding on `*this`.
35+
- In order for the library to work with slightly older compilers, we emulate some missing type traits. On some platforms we cannot correctly detect the available features, and attempts at workarounds for missing type trait definitions can cause compile-time errors. Define macro `TR2_OPTIONAL_DISABLE_EMULATION_OF_TYPE_TRAITS` if you know that all the necessary type traits are defined, and no emulation is required.
36+
37+
License
38+
-------
39+
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).

copyright.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Copyright (C) 2011-2012 Andrzej Krzemienski
2+
3+
Distributed under the Boost Software License, Version 1.0
4+
(see accompanying file LICENSE_1_0.txt or a copy at
5+
http://www.boost.org/LICENSE_1_0.txt)
6+
7+
The idea and interface is based on Boost.Optional library
8+
authored by Fernando Luis Cacciola Carballal
9+
10+
Home at https://github.com/akrzemi1/Optional

0 commit comments

Comments
 (0)