Skip to content

Enh: test brace initialisation with values #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import testing ;
{
test-suite optional :
[ run optional_test.cpp ]
[ run optional_test_braces.cpp ]
[ run optional_test_swap.cpp ]
[ run optional_test_conversions_from_U.cpp ]
[ run optional_test_convert_from_T.cpp ]
Expand Down
51 changes: 51 additions & 0 deletions test/optional_test_braces.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (C) 2016 Jürgen Hunold
//
// 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.


#include "boost/optional/optional.hpp"

#include <iostream>

#include "boost/core/lightweight_test.hpp"

using boost::optional;


struct Init
{
Init(int,double);
};

#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX


template <typename T>
void test_brace_init()
{
optional<T> o = {1, 1.1};
BOOST_TEST(o);
}

template <typename T>
void test_brace_assign()
{
optional<T> o;
o = {1, 1.1};
BOOST_TEST(o);
}
#endif

int main()
{
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
test_brace_init<Init>();
test_brace_assign<Init>();
#endif

return boost::report_errors();
}