2 #ifndef BOOST_CONTRACT_DETAIL_STATIC_LOCAL_VAR_HPP_
3 #define BOOST_CONTRACT_DETAIL_STATIC_LOCAL_VAR_HPP_
5 // Copyright (C) 2008-2018 Lorenzo Caminiti
6 // Distributed under the Boost Software License, Version 1.0 (see accompanying
7 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
8 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
10 namespace boost { namespace contract { namespace detail {
12 // This is used to hold the state of this library (already checking assertions,
13 // failure handers, mutexes, etc.). Local static variables are used instead of
14 // global or class-level static variables to avoid ODR errors when this library
15 // is used as header-only.
17 // Use T's default constructor to init the local var.
18 template<typename Tag, typename T>
19 struct static_local_var {
26 // Use `init` param to init local var (Init same as or convertible to T).
27 // NOTE: Template specializations could be used to program both this and the
28 // template above together but some pre-C++11 compilers give errors (e.g., Clang
29 // without -std=c++11), plus the `_init` postfix is more readable at call site.
30 template<typename Tag, typename T, typename Init, Init init>
31 struct static_local_var_init {
40 #endif // #include guard