Support Class Library
A set of tools providing classes and utility
optional.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <scl/utils/Optional.h>
4 #include <utility>
5 #include <scl/tools/make/from.h>
6 
7 namespace scl{
8  namespace tools{
9  namespace make{
17  template <class T, class... Args>
18  constexpr scl::utils::Optional<T> optional(Args&&... args){
19  return make::from<T>(std::forward<Args>(args)...);
20  }
21 
27  template <class T>
29  return scl::utils::none;
30  }
31 
35  template <class T, class... Args>
36  constexpr scl::utils::Optional<T> some(Args&&... args){
37  return optional<T>(std::forward<Args>(args)...);
38  }
39 
43  template <class T>
45  return emptyOptional<T>();
46  }
47 
54  template <class T>
57  }
58  }
59  }
60 }
constexpr scl::utils::Optional< T > optional(Args &&... args)
Creates an scl::utils::Optional with a constructed value.
Definition: optional.h:18
constexpr scl::utils::Optional< T > optionalFromPointer(const T *ptr)
Creates an optional from a pointer.
Definition: optional.h:55
Global namespace of the SCL.
Definition: alias.hpp:3
T * ptr(Args &&... args)
Creates a pointer in-place with the given set of arguments (using new)
Definition: ptr.h:16
A class that allows the use of optional types (might be there)
Definition: Optional.h:65
Group of factory functions.
Definition: any.h:8
constexpr None none
A constant global variable of type None.
Definition: Optional.h:41
constexpr scl::utils::Optional< T > emptyOptional()
Creates an empty optional.
Definition: optional.h:28
static constexpr Optional fromPointer(const T *ptr)
Construct an optional from a pointer.
Definition: Optional.h:82
constexpr scl::utils::Optional< T > none()
Alias for scl::tools::make::emptyOptional.
Definition: optional.h:44
constexpr scl::utils::Optional< T > some(Args &&... args)
Alias for scl::tools::make::optional.
Definition: optional.h:36