forked from boostorg/optional
experimental optional config test
This commit is contained in:
@ -52,4 +52,11 @@
|
||||
# define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && _MSC_VER <= 1800)
|
||||
// on MSCV 2013 and earlier an unwanted temporary is created when you assign from
|
||||
// a const lvalue of integral type. Thus we bind not to the original address but
|
||||
// to a temporary.
|
||||
# define BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
|
||||
#endif
|
||||
|
||||
#endif // header guard
|
||||
|
@ -60,5 +60,7 @@ import testing ;
|
||||
[ compile-fail optional_test_fail_io_without_io.cpp ]
|
||||
[ compile-fail optional_test_fail_none_io_without_io.cpp ]
|
||||
[ compile-fail optional_test_fail_convert_assign_of_enums.cpp ]
|
||||
[ run optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_pass.cpp ]
|
||||
[ run-fail optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_fail.cpp ]
|
||||
;
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2015 Andrzej Krzemienski.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/lib/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/optional/detail/optional_config.hpp"
|
||||
|
||||
#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_ERROR("failed as requested");
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
const int global_i = 0;
|
||||
|
||||
struct Binder
|
||||
{
|
||||
void operator=(const int& i)
|
||||
{
|
||||
BOOST_TEST(&i == &global_i);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Binder s;
|
||||
s = global_i;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2015 Andrzej Krzemienski.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/lib/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/optional/detail/optional_config.hpp"
|
||||
|
||||
#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
|
||||
|
||||
const int global_i = 0;
|
||||
|
||||
struct Binder
|
||||
{
|
||||
void operator=(const int& i)
|
||||
{
|
||||
BOOST_TEST(&i == &global_i);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Binder s;
|
||||
s = global_i;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2015 Andrzej Krzemienski.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/lib/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/optional/detail/optional_config.hpp"
|
||||
|
||||
#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_ERROR("failed as requested");
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
const int global_i = 0;
|
||||
|
||||
struct Binder
|
||||
{
|
||||
Binder(const int& i)
|
||||
{
|
||||
BOOST_TEST(&i == &global_i);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Binder b = global_i;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2015 Andrzej Krzemienski.
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org/lib/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/optional/detail/optional_config.hpp"
|
||||
|
||||
#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
|
||||
|
||||
const int global_i = 0;
|
||||
|
||||
struct Binder
|
||||
{
|
||||
Binder(const int& i)
|
||||
{
|
||||
BOOST_TEST(&i == &global_i);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Binder b = global_i;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user