⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 odr.hpp

📁 [2005最新C++经典著作].C++ Programming.新手必看的学VC的奠基之著。
💻 HPP
字号:
// Copyright (C) 2004 Arkadiy Vertleyb// Use, modification and distribution is subject to the Boost Software// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)#ifndef ODR_HPP_INCLUDED#define ODR_HPP_INCLUDED#include <boost/spirit/typeof/typeof.hpp>void odr_test1();void odr_test2();// trying to cause ODR violation in a class templatetemplate<class T, class U>class sum_t{public:    typedef BOOST_TYPEOF_TPL(T() + U()) result_type;    sum_t(const T& t, const U& u)        : m_sum(t + u)    {}    BOOST_TYPEOF_TPL(T() + U()) operator()()    {        BOOST_AUTO_TPL(result, m_sum);        return result;    }private:    BOOST_TYPEOF_TPL(T() + U()) m_sum;};template<class T, class U>sum_t<T, U> make_sum(const T& t, const U& u){    return sum_t<T, U>(t, u);}// trying to cause ODR violation in a function templatetemplate<class T, class U>typename sum_t<T, U>::result_type sum(const T& t, const U& u){    BOOST_AUTO_TPL(result, t + u);    return result;}#endif//ODR_HPP_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -