FST  openfst-1.7.2
OpenFst Library
arg-packs.h
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 //
4 // std::pair and std::tuple are used for the arguments of FstClass operations.
5 //
6 // If a function with a return value is required, use the WithReturnValue
7 // template as follows:
8 //
9 // WithReturnValue<bool, std::tuple<...>>
10 
11 #ifndef FST_SCRIPT_ARG_PACKS_H_
12 #define FST_SCRIPT_ARG_PACKS_H_
13 
14 #include <type_traits>
15 
16 namespace fst {
17 namespace script {
18 
19 // Tack this on to an existing type to add a return value. The syntax for
20 // accessing the args is then slightly more stilted, as you must do an extra
21 // member access (since the args are stored as a member of this class).
22 
23 template <class Retval, class ArgTuple>
25  // Avoid reference-to-reference if ArgTuple is a reference.
26  using Args = typename std::remove_reference<ArgTuple>::type;
27 
28  Retval retval;
29  const Args &args;
30 
31  explicit WithReturnValue(const Args &args) : args(args) {}
32 };
33 
34 } // namespace script
35 } // namespace fst
36 
37 #endif // FST_SCRIPT_ARG_PACKS_H_
typename std::remove_reference< ArgTuple >::type Args
Definition: arg-packs.h:26
WithReturnValue(const Args &args)
Definition: arg-packs.h:31