Bond
 
Loading...
Searching...
No Matches
odr.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#pragma once
5
6#include <bond/core/config.h>
7
8#include <boost/assert.hpp>
9
10namespace bond
11{
12
13namespace detail
14{
15
16template <typename T>
17struct counter
18{
19 counter()
20 {
21 // This assert indicates violation of One Definition Rule for T.
22 BOOST_ASSERT(!value++);
23 }
24
25 static int value;
26};
27
28
29template <typename T>
30int counter<T>::value;
31
32}
33
34
35template <typename One, typename Variant>
36struct one_definition
37{
38 static detail::counter<One> value;
39};
40
41
42template <typename One, typename Variant>
43detail::counter<One> one_definition<One, Variant>::value;
44
45
46}
namespace bond
Definition: apply.h:17