Files
optional/test/optional_test_inplace_fail.cpp

53 lines
1.4 KiB
C++
Raw Normal View History

2003-11-03 02:59:08 +00:00
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
// Copyright (C) 2015 Andrzej Krzemienski.
2003-09-10 15:47:00 +00:00
//
2003-11-03 02:59:08 +00:00
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
2003-09-10 15:47:00 +00:00
//
2003-11-03 02:59:08 +00:00
// See http://www.boost.org/lib/optional for documentation.
2003-09-10 15:47:00 +00:00
//
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
#include<string>
#include "boost/optional/optional.hpp"
2003-10-30 14:45:13 +00:00
#ifdef BOOST_BORLANDC
2003-09-10 15:47:00 +00:00
#pragma hdrstop
#endif
2003-10-30 14:45:13 +00:00
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#include "boost/utility/in_place_factory.hpp"
#include "boost/utility/typed_in_place_factory.hpp"
#endif
2003-09-10 15:47:00 +00:00
#include "boost/core/lightweight_test.hpp"
#include "boost/none.hpp"
2003-09-10 15:47:00 +00:00
struct Guard
2003-09-10 15:47:00 +00:00
{
double num;
std::string str;
Guard() : num() {}
Guard(double num_, std::string str_) : num(num_), str(str_) {}
friend bool operator==(const Guard& lhs, const Guard& rhs) { return lhs.num == rhs.num && lhs.str == rhs.str; }
friend bool operator!=(const Guard& lhs, const Guard& rhs) { return !(lhs == rhs); }
private:
Guard(const Guard&);
Guard& operator=(const Guard&);
};
int main()
2003-10-30 14:45:13 +00:00
{
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
int excessive_param = 2;
boost::optional<Guard> og1 ( boost::in_place(1.0, "one", excessive_param) );
#else
NOTHING_TO_TEST_SO_JUST_FAIL
2003-10-30 14:45:13 +00:00
#endif
return 0;
}